Article View: comp.std.c
Article #179Re: PLease advise about "ansi" headers
From: David Adrien Tanguay
Date: Sat, 04 Apr 1992 11:47
Date: Sat, 04 Apr 1992 11:47
50 lines
3048 bytes
3048 bytes
diamond@jit.dec.com (Norman Diamond) writes:
>In article <*}s-pkdc@twinsun.com> eggert@twinsun.com (Paul Eggert) writes:
>>ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) writes:
>>> Am I correct that ANSI header files should be independent of identifiers
>>> available to the user, using instead e.g.
>>> void *malloc(size_t); /* no identifier, or */
>>> void *malloc(size_t _size); /* reserved identifier */
>>You're basically correct. A nit: `_size' isn't reserved (see ANSI C 4.1.2.1).
>>`__size' is, so it would work here.
>
>Mr. O'Keefe's complaint is correct, and his proposed adjustment was correct
>though on thin ice [personal opinion only]. Mr. Eggert's nit is wrong.
>
>The standard headers must be included outside of any external declaration or
>definition (ANSI 4.1.2, page 97 lines 31-32; there are also more requirements).
>
>_size is reserved for use as an identifier with file scope in both the
>ordinary and tag name spaces (ANSI 4.1.2.1, page 98 lines 7-8 and 16-18).
>I think the standard's wording is very unclear on whether _size can be
>declared as a macro, but footnote 88 clarifies the intention, and an
>implementation COULD depend on _size as a reserved identifier at file scope.
ANSI 3.1.2 pg. 21 line 5 "Macro names and macro parameters are not considered
further here", so macro names aren't in the "identifier with file scope"
category, and aren't reserved by 4.1.2.1 lines 7-8.
Footnote 88 says "macro names matching any of the reserved identifier names
must not be defined if an associated header, if any, is included".
^^^^^^^^^^
"_size" is not associated with any of the headers, so I don't think it's
covered by the footnote, either.
Your interpretation seems to say that the user cannot define any macros that
start with an "_", at least if any standard header is included.
>So it's pretty hard to argue that the standard would allow the user to define
>_size as a macro in the part of a file where standard headers can be included.
Hey, it's the weekend, and I'm feeling reckless.
>(However, if I were an implementor, I would use two underscores in all of
>this kind of implementation stuff [personal opinion only].)
Ditto. And, as a user, I never create identifiers that start with an _:
it's a much easier rule to figure out and remember.
Reserved identifiers are strange and striking!
--
David Tanguay dat@Thinkage.on.ca dat@Thinkage.com uunet!thinkage!dat
Thinkage, Ltd. Kitchener, Ontario, Canada [43.40N 80.47W]
Technical Details
Message-ID:
<1992Apr4.114726.3793@thinkage.on.ca>Path:
arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!utgpu!watserv1!watmath!thinkage!datReferences:
<10008@goanna.cs.rmit.oz.au> <*}s-pkdc@twinsun.com> <1992Apr2.010456.10140@news.jit.dec.com>Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c Path: arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!utgpu!watserv1!watmath!thinkage!dat From: dat@thinkage.on.ca (David Adrien Tanguay) Subject: Re: PLease advise about "ansi" headers Message-ID: <1992Apr4.114726.3793@thinkage.on.ca> Keywords: headers, conformance, ansi, hell Organization: Thinkage, Ltd. References: <10008@goanna.cs.rmit.oz.au> <*}s-pkdc@twinsun.com> <1992Apr2.010456.10140@news.jit.dec.com> Date: Sat, 4 Apr 1992 11:47:26 GMT Lines: 50