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: Brendon Costa <brendon at christian dot net>
- To: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- Cc: Brendon Costa <bcosta at avdat dot com dot au>, gcc at gcc dot gnu dot org
- Date: Tue, 28 Nov 2006 07:49:11 +1100
- Subject: Re: Differences in c and c++ anon typedefs
- References: <456A3912.8050403@avdat.com.au> <m34psl628z.fsf@zeus.integrable-solutions.net>
Gabriel Dos Reis wrote:
> 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).
>
As a result of C types not having a "class name for linkage purposes", I
am finding it difficult to define a "normalised" string for
FUNCTION_TYPE nodes that represents the type in the same way across
C/C++ for compatible function types.
Basically I need to save to a file a string that represents a
FUNCTION_TYPE node that can be compared against other strings that also
represent FUNCTION_TYPE nodes and if the two functions are compatible as
would be returned by: function_types_compatible_p() then the strings
should be equal.
In C++ I create the string by using TYPE_MAIN_VARIENT for the various
parts of the FUNCTION_TYPE node (return type, and parameters). Does
anyone have ANY idea of a way I could do something similar in the C
front end?
Thanks,
Brendon.