trouble linking an asm file w/ vC++

Started by
4 comments, last by ranxact 24 years, 6 months ago
Are you looking to use MASM to write those time critical functions but just can't get it into MSVC++???? well so was I... and i found my answer in the microsoft Knowledge base... (microsoft actually helping us??? hmmm..) anyway.. goto article Q106399 (or goto the address i give here) http://support.microsoft.com/support/kb/articles/Q106/3/99.asp?LNG=ENG&SA=PER&FR=0 ps. (i just edited over my original question with this answer because i worded it bad anyway) good luck, RanXact Edited by - ranxact on 2/15/00 10:17:52 PM
RanXact@yahoo.com
Advertisement
You're missing the braces. VC++ requires braces wrapping the function header like so:

extern "C" {
// function header
}

In Borland you can declare without the braces, but in VC++ I'm pretty certain they're required. Also, the docs state calls to MASM generated functions should be declared with __stdcall like this:

extern "C" {
return_type __stdcall FunctionName ();
}

Where return_type is, of course, int, void, float, etc...

I've actually never used __stdcall when calling external assembly routines and I've had no problems. The books I've read do not use it. Now I will after reading the docs.

Another thing, extern "C" is NOT legal in the C language. It can only be used from within C++. If you are declaring functions for C source files only then you do not need the extern "C" syntax.If you have functions to be used with C AND C++ source files, this is how you should declare them:

#ifdef __cplusplus
extern "C" {
#endif

// function headers go here

#ifdef __cplusplus
}
#endif



Edited by - Aldacron on 2/14/00 7:10:39 PM
Thank YOu for the info, but that was only one of my problems. (i was using a c program not c++ to test my funcs.. DOH!) my main problem is that i don''t know how to get VC++ to use the funcitons.. as in the linker cannot find them, or it searches for them in Kernal32.dll....

this is the error when i debug it

Loaded ''C:\WINDOWS\SYSTEM\KERNEL32.DLL'', no matching symbolic information found.
The thread 0xFFF84B83 has exited with code 259 (0x103).
The program ''c:\MASM32\TEMP\Tester\Debug\Tester.exe'' has exited with code 259 (0x103).

but why is it looking there and how do i tell it to look where it should? and for that matter, what file should i give it? really i know it is something stupid... but again help would be appreciated

Thank you,
RanXacT

RanXact@yahoo.com
I''m pretty sure you should add the compiled asm file (the obj file) to the project so it gets linked in with the project''s compiled C/C++ source files... If that''s what you''re asking.

------------------------------
Jonathan Little
invader@hushmail.com
http://www.crosswinds.net/~uselessknowledge

I''ve Found what i was looking for!!!!

all these answers and more have been answered in the microsoft Knowledge Base even though microsoft has just about disowned MASM... they still have a few things left

well, the addy is long, but here it is

http://support.microsoft.com/support/kb/articles/Q106/3/99.asp?LNG=ENG&SA=PER&FR=0

i''d cut and paste it, but it is kinda long.

thank you all for your help...
and i hope that this may be of some help to the other poor clueless souls out there like me ...

RanXacT
RanXact@yahoo.com
ranxact, that''s much for posting this question.. i''d been running into the same thing, and was about to post, but i ran across yours first. again, thanks alot for asking (and answering) the same question i had..

This topic is closed to new replies.

Advertisement