Re: what does __foo means.

From: bert hubert
Date: Tue Dec 07 2004 - 08:13:45 EST


On Tue, Dec 07, 2004 at 01:54:25PM +0100, Jan Engelhardt wrote:
> >Hi all,
> >
> > Can anyone tell me does double underscore before a function mean?
> > In which scenario a programmer must use it.
>
> From the POV of a compiler, _ is like [a-z]. The programmer may use it freely.

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.

I don't have K&R handy to check this. We might have some more liberty
because we do not link in libc.

--
http://www.PowerDNS.com Open source, database driven DNS Software
http://lartc.org Linux Advanced Routing & Traffic Control HOWTO
-
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/