Ask for compile/link options to call gcc functions and called by gcc

Started by coder903, January 24, 2005, 06:49:49 AM

Previous topic - Next topic

coder903

Could anyone provide a sample to get MASM32 proc called by GCC(MinGW) and vice versa?
i guess the OBJ files created by GCC compiler and that by ML.exe are not compatible, each considers the other as undefined symbols or undefined references. i don't know how to make them linked friendly. please help!

coder903

i'd attach my ASM/C source for your reference, in which C_Calling_C and Asm-Calling_Asm works (in mkc.bat and mkasm.bat), but others(mkasmc.bat and mkcasm.bat) ng.
if i posted to a wrong place please get them in the right place and inform me.

[attachment deleted by admin]

Jibz

The default calling convention for C is cdecl, while your asm code is using the stdcall calling convention.

You can try changing .model flat,stdcall to .model flat,c at the top of GetMyText.asm, and GetMyText PROTO to GetMyText PROTO C in main.asm.

Or use a prototype to declare the function as stdcall in cmain.c, like extern const char * __stdcall GetMyText(void); :U.

coder903

Thank you, Jibz. i changed .model flat,stdcall to .model flat,c at the top of GetMyText.asm, and GetMyText PROTO to GetMyText PROTO C in main.asm, all of them work!
i never noticed .model and PROTO directives and i should learn the basics now.