$1 check for first person who convinces me main can't be reserved
Arthur David Olson
ado at elsie.UUCP
Thu Feb 18 12:12:49 AEST 1988
Having grown desperate, I'm stooping to offering a $1 check to the first person
who can convince me that the January 11, 1988 draft C standard prohibits the
implementer of a conforming hosted implementation from deciding that "main" is a
reserved external identifier. All decisions of the judge (me) are final.
Here's the background. The January 11 draft says, among other things:
* "A strictly conforming program shall use only those features of the
language and library speciried in this Standard. It shall not
produce output dependent on any unspecified, undefined, or
implementation-defined behavior. . ." (Page 4, Section 1.7)
* "A conforming hosted implementation shall accept any strictly
conforming program." (Page 4, Section 1.7)
* "All external identifiers declared in any of the headers are
resserved, whether or not the associated header is included. All
external identifiers that begin with an underscore are reserved.
All other identifiers that begin with an underscore and either an
upper-case letter or another underscore are reserved. If the
program defines an external identifier with the same name as a
reserved external identifier, even in a semantically equivalent form,
the behavior is undefined." (Page 97, Section 4.1.2)
Now suppose an implementer decides that "main" is a reserved external
identifier. Nothing in the last section above seems (to me) to prohibit
the implementer from doing so. Nothing above seems (to me) to obligate the
implementer to declare "main" in a header; nor does the implementer have
to list the reserved external identifiers for me in an implementation document
(at least I can't find such a requirement in section A.6.3).
So when I try to use the program
#include "stdio.h"
main() { printf("Hello, world!\n"); return 0; }
I might very well get the output:
Goodbye cruel world!
because I've used a reserved external identifier, which means that my program
isn't strictly conforming, which means that the implementation can do anything
it wants with the program (a license granted by the "undefined behavior"
phrase in the first quote above).
I hope it's clear that I'm not losing sleep over some implementer actually
deciding that main is a reserved external identifier; I am, though, worried
about how I'm supposed to find out just what identifiers an implementer might
have reserved--because if I use one of them, anything at all might happen to
my programs.
I've include a
Followup-To: poster
to try to get responses routed my way; I'll post the first response that
convinces me.
--
I am solely responsible for this posting.
--
ado at vax2.nlm.nih.gov ADO, VAX, and NIH are Ampex and DEC trademarks
More information about the Comp.lang.c
mailing list