leading underscores..

Jerry Feldman gaf at blu.org
Sat Dec 2 17:32:03 EST 2006


On Sat, 02 Dec 2006 16:28:10 -0500
David Kramer <david at thekramers.net> wrote:

> In many environments, leading underscores are used for the name of the
> internal runtime functions that thou shalt not call directly, and this
> is done to prevent name collisions (since it predates namespaces).  It's
> not a good idea to use them in your own code, whether your particular
> environment supports them or not.
Again, I defer to the C standard:
"All identifiers that begin with an underscore and either an upper case
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 identifier and
tag name spaces. "
4.1.2.1

In essence, public funtions and data in run-time libraries normally use
double underscores, for example in libc:
00003b50 T __malloc
00003b50 T malloc

You'll also see that the malloc symbol is set up as a weak symbol. This
allows the application programmer to write a private malloc and
override the system malloc. 


-- 
Jerry Feldman <gaf at blu.org>
Boston Linux and Unix user group
http://www.blu.org PGP key id:C5061EA9
PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9


More information about the Discuss mailing list