1

I write a program in C, in visual studio 2015, and I have a masm module in it. I want to define some of the functions to be called as stdcall instead of the default cdecl. is there a way do that? My goal is to skip the stack cleanup in the caller function.

I have a function in myModule.h

SIZE_T MyFunc(PVOID IN param1, PVOID IN param2);

However adding __stdcall to the function signature in the following way:

SIZE_T __stdcall MyFunc(PVOID IN param1, PVOID IN param2);

yields a linking error:

LNK2019 unresolved external symbol _MyFunc@8

The definition of the function is in myModule.asm, and after removing the __stdcall clause, the code compiles and links correctly.

Does anyone know how to do that in the right way?

I also tried to change the whole .asm file to use stdcall convention, by changing:

properties->configurations properties->microsoft macro assembler->advanced->calling convention

But still the functions are being called as cdecl, when the caller cleans the stack.

Thank you!

zx485
  • 28,498
  • 28
  • 50
  • 59
macro_controller
  • 1,469
  • 1
  • 14
  • 32
  • 5
    For stdcall functions the convention is to append the number of bytes of arguments, so rename your symbol in the asm file to match what you see in the linker error. The leading underscore might be added automatically though. – Jester Jan 02 '17 at 14:13
  • Thanks, that solved it! – macro_controller Jan 02 '17 at 14:40

0 Answers0