[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: RE: Registering C functions in C++ (Win32)
- From: "Curt Carpenter" <curtc@...>
- Date: Thu, 21 Feb 2002 19:17:03 -0800
__declspec(naked) is not what you want. You just gotta make sure you
compile with the same calling convention you biult your Lua binaries
with. Personally, on Windows I use stdcall. Anyway, you can't register a
C++ class member function (unless it's static) since there's an implicit
From: simon [mailto:email@example.com]
Sent: Thursday, February 21, 2002 7:09 PM
To: Multiple recipients of list
Subject: Registering C functions in C++ (Win32)
I'm having a few problems getting around MSVC calling conventions when
registering a function with lua.
For example, in a c++ program, the function
int test(lua_State *L);
is internally translated to int (__cdecl)(struct
You can turn off the __cdecl definition by
substituting the macro __declspec(naked), but that
imposes the restriction of not being able to return a
value (such as int, which is required).
Anybody hurdled this one in MSVC++? I'd like to keep
function call safety in the linker. The complete
compiler error message is:
error C2664: 'lua_pushcclosure' : cannot convert
parameter 2 from 'int (struct lua_State *)' to 'int
(__cdecl *)(struct lua_State *)'
It's a member function, being registered in a
Thanks and regards,
http://movies.yahoo.com.au - Yahoo! Movies
- Vote for your nominees in our online Oscars pool.