[GCC-XML] problem parsing struct declaration

Kang, Gene Y (N-Simulogix) gene.y.kang at lmco.com
Tue Oct 19 11:22:49 EDT 2004


So, is it safe to assume the following 2 structures will generate different results from GCCXML:

typedef struct {
   int a; 
   int b;
   int c;
 
   struct {
      int d_1;
      int d_2;
   } d;
 
   double e;
} stuff_t;

VS.

typedef struct {
   int d_1;
   int d_2;
} d_t

typedef struct {
   int a; 
   int b;
   int c;
   d_t d;
   double e;
} stuff_t;


Gene


-----Original Message-----
From: Brad King [mailto:brad.king at kitware.com]
Sent: Tuesday, October 19, 2004 8:06 AM
To: Kang, Gene Y (N-Simulogix)
Cc: gccxml at gccxml.org
Subject: Re: [GCC-XML] problem parsing struct declaration


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