This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: g++ doesn't accept AIX include file
- To: olvil at wmdata dot com
- Subject: Re: g++ doesn't accept AIX include file
- From: "Martin v. Loewis" <martin at loewis dot home dot cs dot tu-berlin dot de>
- Date: Thu, 9 Dec 1999 13:40:37 +0100
- CC: gcc-bugs at gcc dot gnu dot org, kijer at wmdata dot com
- References: <6746AFC8AB87D311A8E64000830856D210AA45@WMSI000272>
> I read Bjarne Stroustrup: The C++ Programming Language, Second Edition,
> section r.7.1.3 The typedef Specifier. It says among other things:
>
> "An unnamed class defined in a typedef gets its typedef name as its name.
> For example,
>
> typedef struct { (* ... */ } S; // the struct is named S"
Thanks for your bug report. The exact wording in the standard is, from
7.1.3, [dcl.typedef]/3
# If the typedef declaration defines an unnamed class (or enum), the
# first typedefname 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).
They then have the (informal)
# [Note: if the typedefname is used where a classname (or enumname)
# is required, the program is illformed.For example,
#
# typedef struct {
# S(); //error: requires a return type because S is
# // an ordinary member function, not a constructor
# } S;
# -- end note]
So the name is for linkage purposes *only*. That is, when you have
void foo(S*);
void foo(int);
in one translation unit, and
void foo(S*){}
in another, than the definition above refers to the first declaration.
You cannot use the name in an elaborated-type-specifier, since that
would require a class-name.
Hope this helps,
Martin
P.S. If you are not satisfied with this answer, please discuss the
issue in comp.std.c++ first.