Path: utzoo!utgpu!watserv1!watmath!att!att!rutgers!usc!elroy.jpl.nasa.gov!lll-winken!unixhub!shelby!unix!hplabs!nsc!voder!procase!roger From: roger@procase.UUCP (Roger H. Scott) Newsgroups: comp.lang.c++ Subject: Re: 1 Definition Allowed Message-ID: <199@c.procase.UUCP> Date: 3 Nov 90 22:23:04 GMT References: <1990Oct30.125546.3702@kodak.kodak.com> <1463@proto.COM> <1990Nov1.202530.15347@cs.columbia.edu> Reply-To: roger@procase.UUCP (Roger H. Scott) Organization: proCASE Corporation, Santa Clara, CA Lines: 24 In article <1990Nov1.202530.15347@cs.columbia.edu> kearns@cs.columbia.edu (Steve Kearns) writes: >E&S (3.1) says only one definition is allowed per program for any >name. It also claims that "struct S { int a; int b; };" is a >definition of a struct. But this seems to imply that such a struct >declaration cannot appear in a header file which will be included in >more than 1 compilation unit!!!!! Section 3 says that class/struct/union/enum names may or may not be "linked" between files, depending on whether or not they are in any way used to declare objects that have external linkage. This is pretty weird, and it does seem to imply that, for instance, a struct used to declare a global variable *cannot* be defined in more than one file. Clearly this is absurd. As I see it the problem here is that "definition" is the wrong word to use when talking about types (such as structs). ANSI C has the right idea here - definitions allocate storage. If the issues of storage allocation don't apply to the entity in question then the word "definition" doesn't, either. Some other term needs to be coined to describe the difference between "struct S", which is a declaration (though not of an object), and "struct S { int m; }", which is "something else". If we call this "something else" a "complete description", then the rule would be not that any given type must have exactly one complete description within a program, but rather that all complete descriptions of a given type within a program must be identical. Now it becomes a link-level semantics checking problem for an implementation to actually enforce this rule.