From: bert hubert <ahu@ds9a.nl>
To: Jan Engelhardt <jengelh@linux01.gwdg.de>
Cc: krishna <krishna.c@globaledgesoft.com>,
Linux Kernel <linux-kernel@vger.kernel.org>
Subject: Re: what does __foo means.
Date: Tue, 7 Dec 2004 14:11:22 +0100 [thread overview]
Message-ID: <20041207131122.GA25796@outpost.ds9a.nl> (raw)
In-Reply-To: <Pine.LNX.4.53.0412071354060.16729@yvahk01.tjqt.qr>
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
next prev parent reply other threads:[~2004-12-07 13:11 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-12-07 12:45 what does __foo means krishna
2004-12-07 12:54 ` Jan Engelhardt
2004-12-07 13:08 ` Josh Boyer
2004-12-07 13:11 ` bert hubert [this message]
2004-12-07 15:29 ` Jörn Engel
[not found] <fa.gd7ov5r.1n64a8t@ifi.uio.no>
2004-12-07 15:52 ` Bodo Eggert
2004-12-07 22:52 ` Kyle Moffett
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20041207131122.GA25796@outpost.ds9a.nl \
--to=ahu@ds9a.nl \
--cc=jengelh@linux01.gwdg.de \
--cc=krishna.c@globaledgesoft.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox