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);) and that doesn't resolve the issue. Any insight is appreciated. Please let me know if you need more details. Thanks, Vijay -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090122/58e9de40/attachment.html>
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