Problem invoking win32 api calls

Hi,

I use the kaliedoscope tutorial to do some experiments. I’m trying to define a few win32 functions as extern and execute them from the toy language. Functions that take no arguments execute fine (for example, GetLastError()). However, calling functions that do take arguments (for example, SetLastError(unsigned int)) always crash the application due to some kind of stack corruption (Unhandled exception at 0x00000000: 0xC0000005: Access violation reading location 0x00000000.)

I’m actually using the CallingConv::X86_StdCall calling convention for these external functions (F->setCallingConv(CallingConv::X86_StdCall):wink: and that doesn’t resolve the issue.

Any insight is appreciated. Please let me know if you need more details.

Thanks,
Vijay

Hi,

I use the kaliedoscope tutorial to do some experiments. I'm trying to define
a few win32 functions as extern and execute them from the toy language.
Functions that take no arguments execute fine (for example, GetLastError()).
However, calling functions that do take arguments (for example,
SetLastError(unsigned int)) always crash the application due to some kind of
stack corruption (Unhandled exception at 0x00000000: 0xC0000005: Access
violation reading location 0x00000000.)

Sounds like a calling convention issue.

I'm actually using the CallingConv::X86_StdCall calling convention for these
external functions (F->setCallingConv(CallingConv::X86_StdCall):wink: and that
doesn't resolve the issue.

Note that you have to set the calling convention on the call.

-Eli