lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Sat, May 10, 2008 at 12:19 AM, Roberto Ierusalimschy
<roberto@inf.puc-rio.br> wrote:
>> ISO/IEC 14882:1998(E) (according to Google):
>>
>> 17.4.3.1.2 - Global names [lib.global.names]
>>
>> [...]
>
> As a side note, such names are reserved in ISO C too:
>
> ISO/IEC 9899:1999 (E)   (according to ISO :)

Er... I meant that I do not have a copy at hand, and googled up that quote :-)

>
>  7.1.3 Reserved identifiers
>
> 1 [...]
>
>  — 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.

Actually, there is a subtle difference. As I understand, plain C
reserves all names at any scope, which begin with undersore or
uppercase letter. C++ reserves global-scope names with leading
underscore, and names in any scope, if such name contain double
underscore at any position.

That is, to write code to be compiled portably both as C and as C++,
one should not use names with leading underscore and should not use
double underscore at all. If some STL implementation choose to define
some internal macro with the same name as yours, you're in trouble.
For  actual life example, see section "Underhanded Names" in Herb
Sutter's GotW #85 (http://www.gotw.ca/gotw/085.htm).

Alexander.