Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uwm.edu!ogicse!decwrl!shelby!kon@asterix.Stanford.EDU From: kon@asterix.Stanford.EDU (Ronnie Kon) Newsgroups: comp.std.c Subject: Namespace for typedefs Keywords: namespace, name, space, typedef Message-ID: <38@asterix.stanford.edu> Date: 22 Feb 90 22:13:20 GMT Sender: kon@asterix.STANFORD.EDU (Ronnie Kon) Organization: Mindcraft, Inc. Lines: 40 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@mindcraft.com | but mine is really bossy" ...!{decwrl,hpda}!mindcrf!ronnie | -- Laurie Anderson -------------------------------------------------------------------------------