Message-Id: <199909180615.JAA15094@ankara.Foo.COM> From: "S. M. Halloran" Organization: User RFC 822- and 1123-compliant To: djgpp AT delorie DOT com Date: Sat, 18 Sep 1999 10:21:00 +0200 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Subject: Re: assembly procedures w/ extern In-reply-to: <37E31959.A762AD50@powernet.net> X-mailer: Pegasus Mail for Win32 (v3.12) Reply-To: djgpp AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On 17 Sep 99, Bart Trzynadlowski was found to have commented thusly: > Hi, > Ive been tearing my hair out trying to get extern to work in my > DJGPP-compiled programs. What I want to do is have the program call an > assembly subroutine. I declare it with extern but I can't even compile > the program because it complains about an undefined reference. I read > the FAQ and the docs but nothing described my situation. I will be using > NASM externally to assemble the module I need into a .O file, but its > not NASM thats involved, its GCC itself. > > Thanks, > > Bart Trzynadlowski Keep in mind the differences between the various qualifiers. The qualifier 'extern' informs your translation unit (source file) that a global is defined elsewhere and so you are not *DEFINING* it within your translation unit. If your translation unit is a C source, references to globals (either variables or functions) tend to be pre-pended with an underscore. If your C source references the variable: extern int xcounter; then your assembly source should define a global called global _xcounter Now note the use of the qualifier 'global', used by NASM. NASM manual clearly explains the difference between 'extern' and 'global', much like the difference between IMPORT and EXPORT qualifiers, resp., using in making Windows libraries, if the analogy is not strained. The NASM manual says that: global _myvariable both defines the variable and marks it as available for referencing by other translated units (object files), whereas: extern _myvariable says I will use this variable, but don't set aside a place for it, because that has been set aside elsewhere. Check those two things: (1) use of underscores properly, especially if the sources are references between C-coded and assembly-coded files (2) clearing up the confusion between the use of 'global' and 'extern' Mitch Halloran Research (Bio)chemist Duzen Laboratories Group Ankara TURKEY