[net.unix-wizards] What is the origin of the prepended underscore?

jeffg@tekcbi.UUCP (Jeff Glover) (09/04/85)

Why is an underscore commonly prepended to symbols generated by most C
compilers?  Is it archaic, or is there a good reason?  I know library
writers sometimes manually prepend an underscore to hide functions from
casual users, but that is not what I am referring to.

I was asked this question, and was unable to find a satisfactory answer.

Please mail your replies, and I'll summarize for the net.
--
Jeff C. Glover, Tektronix, Inc. PO Box 500, MS Y6-546, Beaverton, OR 97077
{ decvax, allegra, hplabs, ihnp4 } tektronix!tekcbi!jeffg   (503) 627-8438

chris@umcp-cs.UUCP (Chris Torek) (09/06/85)

>Why is an underscore commonly prepended to symbols generated by most C
>compilers?

The answer is so that variables like "r3" don't conflict with
registers like "r3", and so forth.  However, while it is no longer
important now that we have flexnames, I would like to take this
opportunity to wonder why the _ was not *ap*pended to external
symbols, giving one eight significant characters between .o files
instead of seven.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251)
UUCP:	seismo!umcp-cs!chris
CSNet:	chris@umcp-cs		ARPA:	chris@maryland