This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Differences in c and c++ anon typedefs


On Mon, 2006-11-27 at 12:02 +1100, Brendon Costa wrote:
> And apply the TYPE_MAIN_VARIANT on "Another", C++ returns Blah and C 
> again returns the anonymous RECORD_TYPE. In my situation this is causing 
> some grief as i need a consistent name for the main varient type across 
> translation units. 

C and C++ have different rules about compatibilty of structs.  C++ just
mentions that the names have to be the same (and if the elements are
different, the code violates the One Definition rule which means the
code is invalid).  For C, it does not talk about names, instead it
mentions compatibility of struct based on the element layout.

So what you are asking for is really not going to be the right thing.
For full C rules you might able to read the function comptypes_internal
in c-typeck.c or the C standard.  In fact IIRC C99 has slightly
different rules than C89.

Thanks,
Andrew Pinski


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]