Namespace for typedefs
Ronnie Kon
kon at asterix.Stanford.EDU
Fri Feb 23 09:13:20 AEST 1990
The namespace for typedefs is (IMHO) wrong. Currently (according to
the ANSI spec), typedefs are stored in the ordinary identifier namespace,
separate from the label, tags, and struct/union member namespaces. This has
the effect of making the following code fragment legal:
typedef int typename;
struct {
typename typename; /* note: same name */
} x;
(as the occurance of typename as a struct member is in a separate namespace
from the space the typedef is stored in), but
typedef int typename;
typename typename;
is illegal (as the occurance of typename is now in ordinary identifier
namespace, and conflicts with the typedef).
It seems to me to be highly counterintuitive that a declaration that
is legal within a structure becomes illegal when removed from it. (Yes, I
realize that is the case with bit fields, but they are a special case).
What I think should happen is that either typedefs get their own
namespace (my preferred solution), or typedefs should automatically appear
within all struct/union member namespaces.
My questions then, are
1) Do people agree that this is the explanation for the fact
that my compilers (I have tried this on a number of different
machines) accept the first fragment but reject the second?
2) Do other people believe that this should be changed?
--
-------------------------------------------------------------------------------
Ronnie Kon | "I don't know about your brain,
ronnie at mindcraft.com | but mine is really bossy"
...!{decwrl,hpda}!mindcrf!ronnie | -- Laurie Anderson
-------------------------------------------------------------------------------
More information about the Comp.std.c
mailing list