Article View: comp.std.c
Article #180Re: Name space question
From: John F. Woods
Date: Mon, 06 Apr 1992 16:07
Date: Mon, 06 Apr 1992 16:07
31 lines
1754 bytes
1754 bytes
fred@mindcraft.com (Fred Zlotnick) writes:
>The C standard reserves certain name spaces for the implementor: __*,
>_[A-Z]*, and for identifiers with file scope (and this is where my
>question arises) _*. (See section 4.1.2.1 of the ANSI edition, or,
>according to Plauger's book, clause 7.1.3 of the ISO edition, of the
>Standard.)
>Suppose an implementation header defines a macro
> #define _toupper(ch) ( (ch) + 'A' - 'a' )
>or something similar. (This is quite common.) Does this step on the
>application's namespace? An application is free to declare an identifier
>"_toupper" as long as it does not have file scope. Can such a
>declaration ever get expanded by the macro? This is a function-like
>macro, and thus is only expanded when the identifier is immediately
>followed by a left parenthesis. So I guess my question is: Can an
>identifier that is not an external identifier ever legally be followed
>by a left parenthesis?
main() {
int blee;
double _toupper();
/* code which does not use _toupper() */
}
This code fragment declares an identifier _toupper with block scope, which
is legal (as long as the program does not create a declaration with file
scope, which means the program can't actually use the function). Declaring
a macro with that name would probably make the program fail to compile.
I think, therefore, that the implementation may not #define _[0-9a-z]*
identifiers, since they are not reserved for all scopes.
Technical Details
Message-ID:
<11213@ksr.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!world!ksr!jfwReferences:
<1992Apr4.011606.23687@mindcraft.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!world!ksr!jfw From: jfw@ksr.com (John F. Woods) Newsgroups: comp.std.c Subject: Re: Name space question Message-ID: <11213@ksr.com> Date: 6 Apr 92 12:07:39 EDT References: <1992Apr4.011606.23687@mindcraft.com> Sender: news@ksr.com Lines: 31