Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9155933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:40:58+00:00 2026-06-17T12:40:58+00:00

I have two types. One Type A and one Type B. The Problem Type

  • 0

I have two types. One Type A and one Type B. The Problem Type A contains Type B and Type B contains Type A. Such a thing like this won’t work:

  type
    typeA = record
       test1 : typeB;
    end;
  type
    typeB = record
       test2 : typeA;
    end;

Edit:
Thats not my design. I converting C Header files (to access a DLL) that include such constructs to delphi.

Edit2:
“C++ structs are another name for classes AFAIR. And there must have been pointers, not values themselves. – Arioch ‘The 1 min ago”
Yes you are right that was a Pointer to a Type:

There I definied:

test1 : ^typeB;

Will that work instead?

test1 : Pointer;

Edit3:
The C Structs:

/* DLPDFPAGE */
typedef struct dlpdfpage
{
    CosObj              Page;
    CosObj      PrintSelect;
    ASFixedRect         PageBBox;
    ASFixedRect         ContentBBox;
    struct dlpdfpage    *Next;
    PDRotate            Angle;
    struct dlpdfdoc     *Doc;
    DLPDFSTREAM         *Content;
    long                PageNumber;
    char                Complete;
    char                FontSubstituted;
    char                FontMM;
    char                FontBad;
} DLPDFPAGE;


/* DLPDFDOC */
typedef struct dlpdfdoc
{
    DLPDFINSTANCE       *dliInstance;
    PDDoc               pdDoc;
    CosDoc              cosDoc;
    DLPDFOUTLINE        *Outlines;
    char                *PDFFileName;
    char                *PDFPostFileName;
    DLPOS               LastPageEnd;
    DLPOS               BeforeDef;
    ASFixedRect         DocBBox;
    long                PageCount;
    long                PageTreeWidth;
    long                PageTreeDepth;
    long                PageTreeDepthUsed;
    DLPDFPAGETREEARRAY  *AllPages;
    DLPDFFONTLIST       *AllFonts;
    DLPDFFORMLIST       *AllForms;
    DLPDFFORMLIST       *AllColors;
    DLPDFIMAGELIST      *AllImages;
    DLPDFSPOTCOLORLIST  *AllSpotColors;
    DLPDFSPOTCOLORLIST  *AllPatterns;
    DLPDFEXTGSTATELIST  *AllExtGStates;
    DLPDFPAGE           *PageList;
    DLPDFPAGE           *LastPage;
    DLPDFDEST           *DeferedDests;
    DLPDFSIGNATURE      *signatureHolder;
    struct dlpdfacroform *AcroFormBase;
    CosObj              PatternColorObj,
                        PatternColorRGBObj,
                        PatternColorCMYKObj,
                        PatternColorGrayObj,
            PrintSelect,
            PrintSelectCriteria;
    CosObj      IdentH, IdentV;
    ASAtom              DocumentEncoding;
    long                FontCount;
    long                FormCount;
    long                PatCount;
    long                ImageCount;
    char                Compress;
    char                Linearize;
    char                PageTreeComplete;
    char                EmbedFonts;
    char                PatternColorsDefined;
    char                MakeThumbNails;
    ASBool              psSevenBitSafe;
    ASInt32             EncryptKeyByteCount;

    char                condenseResDicts;
    CosObj              resourceDict;  

    ASInt16             pdfMajorVer;    
    ASInt16             pdfMinorVer;    

    DLPDFINCLUDEDRES    *InclRes;       

    DLPDFSPOTCOLORLIST  *AllShadings;
    long                ShadeCount;

} DLPDFDOC;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T12:40:59+00:00Added an answer on June 17, 2026 at 12:40 pm

    You misunderstood what those C structs represent. That’s because a record is a value type: it’s stored right there where you declare the variable. So let’s do a few levels of recursive declarations, and you’ll understand what I mean; Assuming the two structures aren’t absolutely identical:

    type
      TA = record
         test1 : TB;
         SomethingElseFromA: Byte;
      end;
    
      TB = record
         test2 : TA;
         SomethingElseFromB: Byte;
      end;   
    

    Structure TA could be rewritten to mean this:

    type
      TA = record
        // Replaced test1 : TB with the actual content of TB, because that's
        // what a record means.
        test1_test2: TA;
        test1_SomethingElseFromB: Byte;
    
        SomethingElseFromA: Byte;
      end;
    

    Of course, we’ve now got a nice recursive inclusion of self into the TA record, something along the lines of:

      TA = record
        // Replaces test1_test: TA
        test1_test2: TA; // Oops, still not fixed, need to do it again...
        test1_SomethingElseFromB: Byte;
        SomethingElseFromA: Byte;
    
        test1_SomethingElseFromB: Byte;
        SomethingElseFromA: Byte;
      end;
    

    You probably want to use reference types to get something that looks similar, but it’s not similar. A reference type is always a pointer, so it’s a fixed size; The compiler can allocate it without a problem. This would be valid, using pointers-to-records:

    type
      pTypeB = ^typeB;
      pTypeA = ^typeA;
    
      typeA = record
         test1 : pTypeB;
      end;
    
      typeB = record
         test2 : pTypeA;
      end;
    

    Alternatively you could use classes; That works for the same reason, classes are reference types; they work the same way as pointers. When you declare a variable of pointer-type, the compiler allocates SizeOf(Pointer) bytes.


    Since you’ve posted the C structs, I can tell they’re too long for me to attempt a complete translation, but I can make a few suggestions: You should declare all your types in a single Type block; don’t write the Type before each type declaration. This allows you to create the pointer type before the record type, like this:

    Type
      PMyRecord = ^TMyRecord;
    
      // Somewhere in the same Type block
      TMyRecord = record
      end;
    

    For each type that requires pointers-to-records, declare the pointers first thing after the Type keyword, it’s simpler that way. Next, you need to identify the C pointers. If there’s a * between the name of the data type and the name of the field, that’s a pointer. This is usually written like this:

    int *PointerToSomeInt;
    

    But those would be just as valid:

    int * PointerToSomeInt;
    int* VarName1, * VarName1, * VarName3; // Three pointers to integer.
    

    Finally, you’ll need to deal with alignment issues. If you can, check the size of the structures on the C side, and then check the size on the Delphi side: you should get the same size. If you don’t, you should try a couple of random {$ALIGN} compiler directives before your structure declaration and repeat until you strike the correct alignment. If all else fails you’ll need to find what’s wrong (what fields are aligned differently on the Delphi side) and put in some alignment bytes to artificially fix it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this type of structure <ul> <li>one</li> <li> two has children <ul> <li>a</li>
I have two types of data sets. Both are in same size. One contains
I have two simple classes, very simple One is like master table and contains
I have two DropDownLists one for the type of a soldier and one for
I have two maps of type Map<Long, Integer>, one named oldValues representing the old
I have two traits, each with a type parameter for one of its members.
If I have two types of strings as: const char *str1 = This is
I am using eclipse and I have two TextField such that one text field
I have a class LINE which contains two properties of type POINT. I would
There are two tables, which have a relationship(one-to-many). There are Meals table which contains

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.