Re: what does __foo means.

From: Jörn Engel
Date: Tue Dec 07 2004 - 10:31:07 EST


On Tue, 7 December 2004 14:11:22 +0100, bert hubert wrote:
>
> Nonsense. The _ is used to provide for a new namespace, __ for a second one.
> It is common to have a public function 'foo()' which does lots of error
> checking and has a stable api. foo() in turn calls _foo() to do the actual
> work, perhaps doing additional checking and verification.
>
> The _namespace is bound by certain rules, some of which apply to the kernel
> as well. The compiler is free to output symbols in the _Namespace, as well
> as in the __namespace.
>
> "To get specific, identifiers with two leading underscores are reserved for
> the compiler as well as identifiers beginning with a single underscore and
> using an upper case alphabetic character for the second. "
>
> The linux kernel breaks this by using __ for even more private things.

C99:
"All identifiers that begin with an underscore and either an uppercase
letter or another underscore are always reserved for any use."

That applies to normal userspace programs. It allows compiler, libc
and possibly the kernel to introduce new identifiers without breaking
existing programs. If programs break, it is their fault, they
shouldn't have used such identifiers.

The kernel is quite different. Basically, all identifiers belong to
the kernel, none to libc/gcc (with very few exceptions). So
developers are free to use that at their pleasure and most stick to
your description in the first paragraph.

Jörn

--
You cannot suppose that Moliere ever troubled himself to be original in the
matter of ideas. You cannot suppose that the stories he tells in his plays
have never been told before. They were culled, as you very well know.
-- Andre-Louis Moreau in Scarabouche
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/