This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Differences in c and c++ anon typedefs
- From: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- To: Brendon Costa <bcosta at avdat dot com dot au>
- Cc: gcc at gcc dot gnu dot org
- Date: 27 Nov 2006 03:40:28 +0100
- Subject: Re: Differences in c and c++ anon typedefs
- References: <456A3912.8050403@avdat.com.au>
Brendon Costa <bcosta@avdat.com.au> writes:
| Hi all,
|
| I have just come across a small difference in the way the C an C++
| front ends handle anonymous struct types which is causing me some
| grief. In particular the following code:
|
| typedef struct
| {
| int b1;
| int b2;
| } Blah;
|
| void Function(Blah* b) {}
|
| When i get the Blah type in the function above (After removing the
| pointer) i then use TYPE_MAIN_VARIANT on it and do some special
| processing on the resulting main varient type.
C++ defines a notion of "class name for linkage purpose" -- that is a
notion used to define the One Definition Rule.
In general the TYPE_NAME of TYPE_MAIN_VARIANT is the class name for
linkage purpose.
The behaviour you reported on implements the rule 7.1.3/5:
If the typedef declaration defines an unnamed class (or enum), the
first typedef-name declared by the declaration
to be that class type (or enum type) is used to denote the class type
(or enum type) for linkage purposes only (3.5).
-- Gaby