[GCC-XML] problem parsing struct declaration

Brad King brad.king at kitware.com
Tue Oct 19 11:05:40 EDT 2004


Kang, Gene Y (N-Simulogix) wrote:
> GCC-XML seems to parse the following structure incorrectly due to the variable "d" structure declaration.
> 
> typedef struct {
>    int a; 
>    int b;
>    int c;
> 
>    struct {
>      int d_1;
>      int d_2;
>    } d;
> 
>    double e;
> } stuff_t;
> 
> For example, the resulting XML output for stuff_t is:
> 
> <Struct id="_5" name="stuff_t" context="_1" mangled="7stuff_t" location="f0:16" file="f0" line="16" size="256" align="64"
> members="_7 _8 _9 _10 _11 _12 _13 _14 " bases=""/>
> 
> Everything looks good except for "_12".  "_12" looks like a reference to an anonymous struct that's the same type as
> that of d ("_10") :
> 
> <Struct id="_12" context="_5" mangled="N7stuff_t3._1E" location="f0:10" file="f0" line="10" artificial="1" size="64" align="32"
> members="_16 _17 _18 _19 " bases=""/>
> 
> Is this what would be expected from the compiler?...if it is, sorry for the dumb question.  Note, I don't see this problem
> if I change the struct declaration of "d" to a typedef.

Yes, this is the expected output.  The syntax

struct {...} d;

declares a variable "d" whose type is an anonymous struct.

The syntax

typedef struct {...} d;

defines a type "d" refering to the anonymous struct.  No variable is 
created.

-Brad



More information about the gccxml mailing list