[LLVMdev] Problem invoking win32 api calls (Eli Friedman)

Vijay D techvd at gmail.com
Fri Jan 23 17:26:53 PST 2009


That worked perfectly! Thanks!

---------- Forwarded message ----------
From: Eli Friedman <eli.friedman at gmail.com>
To: LLVM Developers Mailing List <llvmdev at cs.uiuc.edu>
Date: Thu, 22 Jan 2009 18:52:22 -0800
Subject: Re: [LLVMdev] Problem invoking win32 api calls
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090123/35945845/attachment.html>


More information about the llvm-dev mailing list