Differences in c and c++ anon typedefs
Brendon Costa
brendon@christian.net
Mon Nov 27 21:27:00 GMT 2006
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.
More information about the Gcc
mailing list