delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/10/12/16:54:05

Date: Mon, 12 Oct 1998 22:52:06 +0200 (MET DST)
From: Wojciech Piechowski <voyt AT ds2 DOT pg DOT gda DOT pl>
To: djgpp AT delorie DOT com
Subject: Re: linking from nasm
In-Reply-To: <Pine.GSO.3.96L.981012134800.4282A-100000@unixs3.cis.pitt.edu>
Message-ID: <Pine.GSO.3.96.981012223701.24539B-100000@delta.ds2.pg.gda.pl>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com

On Mon, 12 Oct 1998, Mark A Reed wrote:

> I have a global function in my file assembled by NASM.
> I want to use that in my .cpp file compiled by DJGPP. But, it keeps saying
> can't find myGlobalFunc. How exactly do you link in the file? heres my
> assembly code and cpp code.
> 
> global _myfunc
> _myfunc: push ebp
>          mov ebp,esp
>          mov eax,[ebp+8]
>          leave
>          ret
> 
> now in my .cpp file
> 
> #include <iostream.h>

> extern int _myfunc(int);

You should prevent the compiler from mangling the function name (or use
the manged one in the assembly file - doesn't look nice and you don't need
this now). The second thing is that the underscore should not be here - it
is automatically inserted by the compiler.

Better do this:

extern "C" int myfunc(int);

--------------------\  Wojciech  Piechowski  /----------------------------
Student informatyki   \ voyt AT ds2 DOT pg DOT gda DOT pl /   Student of computer science
Politechnika Gdanska    \________________/  Technical University of Gdansk

- Raw text -


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