On 25 Sep 2003 15:07:00 GMT, Joona I Palaste <palaste@cc.helsinki.fi>
wrote in comp.lang.c:
[color=blue]
> BruceS <nobody@nospam.net> scribbled the following:[color=green]
> > "Ben Pfaff" <blp@cs.stanford.edu> wrote in message
> > news:87fzil4z8i.fsf@pfaff.stanford.edu...[color=darkred]
> >> "Malcolm" <malcolm@55bank.freeserve.co.uk> writes:
> >> > It is annoying if your compiler comes with a header that declares "null"
> >> > because of the possibility of confusion. "null" may well be decared the[/color]
> > same[color=darkred]
> >> > as NULL, or there may be some subtle difference, for instance "null"[/color]
> > might[color=darkred]
> >> > not be cast to a void * type. You need to check your compiler[/color]
> > documentation[color=darkred]
> >> > for details.
> >>
> >> The compiler is not allowed to declare `null' in any of the
> >> standard header. `null' is not part of the reserved namespace.[/color][/color]
>[color=green]
> > IOW, a conforming implementation must accept something like:[/color]
>[color=green]
> > #include <stdio.h>[/color]
>[color=green]
> > static int new( int class, int object )
> > {
> > return class - object;
> > }[/color]
>[color=green]
> > int main(void)
> > {
> > int null = 12;
> > int instanceof = 54;[/color]
>[color=green]
> > printf("%d\n", new(instanceof, null) );
> > return 0;
> > }[/color]
>
>[color=green]
> > ? (assuming I've not introduced an unrelated error)[/color]
>
> Yes. The implementation is allowed to reserve these kind of names
> for itself:[/color]
Sorry, but all three of these are just a little bit wrong. I've
pasted in text from the current standard (but it has been the same
since ANSI 89):
[color=blue]
> - anything starting with "mem" or "str" and including zero or more
> lowercase letters after that[/color]
"7.26.11 String handling <string.h>
1 Function names that begin with str, mem, or wcs and a lowercase
letter may be added to the declarations in the <string.h> header."
So it's "one or more", not "zero or more".
[color=blue]
> - anything starting with "E" and including one or more uppercase
> letters after that[/color]
"7.26.3 Errors <errno.h>
1 Macros that begin with E and a digit or E and an uppercase letter
may be added to the declarations in the <errno.h> header."
So it's also E followed by a digit. E2 is reserved, for example.
[color=blue]
> - anything starting with an underscore[/color]
"7.1.3 Reserved identifiers
1 Each header declares or defines all identifiers listed in its
associated subclause, and optionally declares or defines identifiers
listed in its associated future library directions subclause and
identifiers which are always reserved either for any use or for use as
file scope identifiers.
— All identifiers that begin with an underscore and either an
uppercase letter or another underscore are always reserved for any
use.
— All identifiers that begin with an underscore are always reserved
for use as identifiers with file scope in both the ordinary and tag
name spaces."
So the identifiers _1, _2, and so on, are in the user namespace, as
are _local and such, with a lower case letter in block scope
variables, and so on.
[color=blue]
> Other than those three, you're free to use any names you please, as
> long as they don't contradict with standard names or keywords.[/color]
Joona, are you familiar with the American slang expression, "Close,
but no cigar"?
--
Jack Klein
Home:
http://JK-Technology.Com
FAQs for
comp.lang.c
http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++
http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
ftp://snurse-l.org/pub/acllc-c++/faq