RAD Studio |  |

Untagged Structures And Typedefs

If you omit the structure tag, you can get an untagged structure. You can use untagged structures to declare the identifiers in the comma-delimited struct-id-list to be of the given structure type (or derived from it), but you cannot declare additional objects of this type elsewhere

Copy Code

    struct { ... } s, *ps, arrs[10]; // untagged structure

It is possible to create a typedef while declaring a structure, with or without a tag:

Copy Code

    typedef struct mystruct { ... } MYSTRUCT;
    MYSTRUCT s, *ps, arrs[10];       // same as struct mystruct s, etc.
    typedef struct { ... } YRSTRUCT; // no tag
    YRSTRUCT y, *yp, arry[20];

Usually, you don't need both a tag and a typedef: either can be used in structure declarations.

Untagged structure and union members are ignored during initialization.

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!