That worked perfectly! Thanks!<br><br>---------- Forwarded message ----------<br>From: Eli Friedman <<a href="mailto:eli.friedman@gmail.com">eli.friedman@gmail.com</a>><br>To: LLVM Developers Mailing List <<a href="mailto:llvmdev@cs.uiuc.edu">llvmdev@cs.uiuc.edu</a>><br>
Date: Thu, 22 Jan 2009 18:52:22 -0800<br>Subject: Re: [LLVMdev] Problem invoking win32 api calls<br>On Thu, Jan 22, 2009 at 6:43 PM, Vijay D <<a href="mailto:techvd@gmail.com">techvd@gmail.com</a>> wrote:<br>
> Hi,<br>
><br>
> I use the kaliedoscope tutorial to do some experiments. I'm trying to define<br>
> a few win32 functions as extern and execute them from the toy language.<br>
> Functions that take no arguments execute fine (for example, GetLastError()).<br>
> However, calling functions that do take arguments (for example,<br>
> SetLastError(unsigned int)) always crash the application due to some kind of<br>
> stack corruption (Unhandled exception at 0x00000000: 0xC0000005: Access<br>
> violation reading location 0x00000000.)<br>
<br>
Sounds like a calling convention issue.<br>
<br>
> I'm actually using the CallingConv::X86_StdCall calling convention for these<br>
> external functions (F->setCallingConv(<div id=":8i" class="ArwC7c ckChnd">CallingConv::X86_StdCall);) and that<br>
> doesn't resolve the issue.<br>
<br>
Note that you have to set the calling convention on the call.<br>
<br>
-Eli</div>