lkml.org 
[lkml]   [2008]   [Oct]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [git pull] x86 updates for v2.6.28, phase #1
Linus Torvalds wrote:
>
> Yeah. If I recall the namespace rules correctly, you have to have a
> underscore followed by another underscore or an upper-case letter. Those
> cannot even be used for local variables by a conforming program.
>
> Single-underscore + lower-case letter is only reserved as an external
> identifier. I _think_.

Strictly speaking, they are "reserved for identifiers with file scope in
both identifier and tag space" (POSIX.1-2004, xsi § 2.2.2, lines 718-).

> So a conforming program could still do
>
> int main(int argc, char **argv)
> {
> int _asm_x86_types_h = 1;
> return _asm_x86_types_h;
> }
>
> and I _think_ it should be ok.

Correct.

> So a system macro definition that could mess with something (admittedly
> crazy as that) has to be either double underscores or underscore +
> uppercase, so as long as the prefix is "_ASM" (or _LINUX), we're ok.
>
> Double underscores in the _middle_ of the identifiers are a non-issue, and
> are just ugly.

Double underscores when used in external identifiers (not an issue here)
can conflict with some C++ mangling schemes, in particular the old
Cfront scheme (which had to be compatible with a standard C compiler.)
gcc seems to use another scheme, but it doesn't either appear to include
any non-C characters, which means it's at least theoretically possible
to step on its toes.

>> That being said, I don't personally like the double underscores.
>
> I agree, inside the identifier in particular they do seem pointless. At
> the beginning, they are useful for things like __i386__ or __x86, where
> you need the double underscore because 'i' is lower-case.
>
> Or maybe I mis-remember the name space rules.

No, you're right on track.

There is an additional rule, which is _de_facto_ since it is out of
scope for the standards: identifiers of the form __foo__ (double
underscores at the start *and* end) are often considered reserved for
the *compiler*.

-hpa
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2008-10-10 23:25    [W:0.571 / U:0.268 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site