[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: LuaJIT FFI callbacks (was Re: Calling lua functions from C when using luajit ffi.)
- From: James McKaskill <james@...>
- Date: Tue, 15 Nov 2011 00:15:39 -0500
On Nov 14, 2011, at 19:30 , Duncan Cross wrote:
>
> This is fantastic news! Thanks so much for your work, and thanks too
> to the anonymous sponsor.
>
> One thing - I'm not certain this is related to the addition of
> callbacks, but I was just experimenting with Win32 calls and found
> that GetLastError() seems to return the wrong value (127,
> ERROR_PROC_NOT_FOUND) the first time it's called. This is a minimal
> test case:
>
> local ffi = require("ffi")
>
> ffi.cdef [[
> uint32_t GetLastError();
> void SetLastError(uint32_t code);
> ]]
>
> ffi.C.SetLastError(0)
> print(ffi.C.GetLastError()) -- 127
> ffi.C.SetLastError(0)
> print(ffi.C.GetLastError()) -- 0
>
> (I'm explicitly setting the error here, but I discovered it because it
> was hiding a parameter error while I was experimenting with trying to
> call RegisterClassExA().)
>
> -Duncan
>
I would not suggest trying to get errors using Get/SetLastError as they will be invalidated by the vm. If you really want the error use ffi.errno().
-- James
Attachment:
smime.p7s
Description: S/MIME cryptographic signature