delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/03/27/10:49:11

From: broeker AT physik DOT rwth-aachen DOT de
Newsgroups: comp.os.msdos.djgpp
Subject: Re: compiling with external assembly files
Date: 27 Mar 2000 14:23:38 GMT
Organization: Aachen University of Technology (RWTH)
Lines: 23
Message-ID: <8bnqta$gp8$1@nets3.rz.RWTH-Aachen.DE>
References: <38DD15E3 DOT BD51AB28 AT hotmail DOT com>
NNTP-Posting-Host: acp3bf.physik.rwth-aachen.de
X-Trace: nets3.rz.RWTH-Aachen.DE 954167018 17192 137.226.32.75 (27 Mar 2000 14:23:38 GMT)
X-Complaints-To: abuse AT rwth-aachen DOT de
NNTP-Posting-Date: 27 Mar 2000 14:23:38 GMT
Originator: broeker@
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Heavy <heavier AT hotmail DOT com> wrote:
> Hi, I'm having a problem with an assembly file I am trying to compile
> along with the rest of my program. It is a .s file,
[...]
> I have tried to #include it in a related .cpp file, 

Completely the wrong way...

> I have linked it as a .o file, but I get an "undefined reference to
> myFunction(...)" error.  I have prototyped the function in a header
> file as extern, and I still get the error.

That's the right method, but you've probably missed one crucial bit:
C++ function name mangling. You'll have to prototype it as

	extern "C" myFunction();

(add return type and arguments yourself) to tell C++ that this is a
function with 'C-style binding', i.e. it's not a function compiled by
a C++ compiler.
-- 
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019