Mail Archives: djgpp/1998/10/12/16:54:05
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 -