I am using MS Visual C++ 6, with this code in "main.c":
#include
int dev1(); //asm function
void main(void)
{
int a=0;
a=dev1();
printf("%d",a);
}
and the "dev1.asm" compiled to "dev1.obj" with "nasm -fwin32 de1.asm":
BITS 32
global _dev1
section .text
_dev1:
enter 0,0
mov eax,1
leave
ret
- It works OK, but if I change the "main.c" to "main.cpp" it fails:
Linking...
main.obj : error LNK2001: unresolved external symbol "int __cdecl dev1(void)" (?dev1@@YAHXZ)
Debug/nasm.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
- Then, how can I mix ASM with C++? It is important to use ASM with Classes, that are C++.