Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83 (MC840302); site kuling.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!mcvax!enea!kuling!thomas From: thomas@kuling.UUCP (Thomas H{meenaho) Newsgroups: net.lang.c,net.unix-wizards Subject: Re: Prepending _ in C external names necessary? Message-ID: <851@kuling.UUCP> Date: Thu, 21-Nov-85 01:08:40 EST Article-I.D.: kuling.851 Posted: Thu Nov 21 01:08:40 1985 Date-Received: Sat, 23-Nov-85 10:14:41 EST References: <1232@hpda.UUCP> Reply-To: thomas@kuling.UUCP (Thomas H{meenaho) Organization: The Royal Inst. of Techn., Stockholm Lines: 37 Xref: linus net.lang.c:6587 net.unix-wizards:12978 In article <1232@hpda.UUCP> davel@hpda.UUCP (Dave Lennert) writes: >We're considering changing our C compiler to *not* prepend an underscore >at the beginning of all external names (functions, variables). Will this >break things? Are there reasons (technical/religious) that we should not >do this? I say don't do it! In one particular C compiler I've seen one can produce perefectly good C code that doesn't work when compiled! Consider the following small example from a 68K machine running V7: main(){ extern long a7; /* perfectly legal declaration */ a7 = 0x1234; } As the variable a7 is declared as external the compiler doesn't allocate any space for it but assumes it will be defined at link time. If I compile this into assembler the resulting code looks something like this: main: link a6,#0 move.l #0x1234,a7 unlk a6 rts As a7 is the stackpointer on a 68K the result will be at best unpredictable with another program! Needless to say the behaviour is the same for any legal register name. -- Thomas Hameenaho, Dept. of Computer Science, Uppsala University, Sweden Phone: +46 18 138650 UUCP: thomas@kuling.UUCP (...!{seismo,mcvax}!enea!kuling!thomas)