Hi!
I'm sorry that I double post (similar posting in the campus), but I think it's better suited here for the people to read it that might know an answer.
Currently I've some masm-assembly as .asm file that is part of a tiny Visualc++6-project. In the .cpp file I declare global variables N, B of type unsigned int that I want to access:
However
---------------------------------
.686
.model flat, stdcall
option casemap :none
Extern _B:DWORD
Extern _N:DWORD
.code
...
--------------------------------
doesn't link. It doesn't work with and without the leading underscores and neither with 'C' instead of stdcall.
How can I access them?
Thanks a lot for your reply! Hannes
Hannes,
MASM has the correct notation to read an external value with EXTERNDEF but you will have to read up on the VC compiler to find the method of making a global variable visible. In MASM you use PUBLIC and this may be a hint of what to do in VC.
In your .cpp file declare your variables with extern "C". Make sure you have the correct case, as the default for linking C++ code is case-sensitive names.
extern "C" unsigned int N, B;
As a further check, look at the linker error messages, as they will tell you what names the C++ compiler created for linking purposes.
Thanks tenkey, extern "C" is the main trick :U