[LLVMdev] Problem invoking win32 api calls

Eli Friedman eli.friedman at gmail.com
Thu Jan 22 18:52:22 PST 2009


On Thu, Jan 22, 2009 at 6:43 PM, Vijay D <techvd at gmail.com> wrote:
> 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);) and that
> doesn't resolve the issue.

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

-Eli



More information about the llvm-dev mailing list