Topic: Reserved names (was The bool portability problem)
Author: jamshid@ses.com (Jamshid Afshar)
Date: 1995/04/25 Raw View
In article <3navkh$88@proxim.franken.de>,
Guus C. Bloemsma <guus@proxim.franken.de> wrote:
>In article <9510911.27608@mulga.cs.mu.OZ.AU> fjh@munta.cs.mu.OZ.AU (Fergus
>Henderson) writes:
>> That is a bad example, since the name `_BOOL_H_' (like others starting
>> with an underscore and an uppercase letter) is reserved for use by the
>> implementation. You should use plain `BOOL_H' or, if you must,
>
>Is this defined in the standard (draft), or is it an
>implementation-specific convention?
>
>Does it only apply to macros, or are all identifiers starting with
>underscore and uppercase letter reserved?
The ANSI/ISO Working Paper (17.1.4 of the January 1994 copy) reserves
all identifiers beginning with an underscore and followed by either
another underscore or a capital letter for the C++ implementation.
For example, a compiler might use _BOOL_H in a #ifndef guard in its
own standard headers, or it might use it as a special keyword. Don't
use such an identifier for anything.
Identifiers beginning with a single underscore followed by a lowercase
letter or digit (e.g., "_bool_h") are reserved at file scope for
things like internal compiler functions or struct names. But, you can
use such identifiers for struct/class member names or local variables
(ie, they're not allowed to be keywords or macro definitions).
Also, an identifier containing consecutive underscores is reserved for
extern linkage. This means you can't define a function or global
variable named "foo__bar". As far as I know this is the only rule
that doesn't also apply to C (it was introduced because some C++
compilers use a name mangling scheme that uses double underscores).
--Jam