[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: A problem about extending lua
- From: Matt Campbell <mattc@...>
- Date: Tue, 04 Apr 2006 21:41:58 -0500
Hello Chen:
What operating system are you running on, and what is the definition of
LUAELALIB_API? Also I'm guessing you're building your extension as a
shared library or DLL; if so, what are you calling that library? I'm
not sure what's causing memory corruption, but I'd rewrite the code you
provided as follows:
static const luaL_Reg elalualib[] = {
/* add any global functions here */
{NULL, NULL}
};
LUAELALIB_API int luaopen_elalua(lua_State *L) {
luaL_register(L, "elalua", elalualib);
/* The elalua table is now on the stack; add any manipulation of that
table here. */
return 1;
}
On Windows, if you're building your extension as a DLL, LUAELALIB_API
should be defined as __declspec(dllexport). Also, if you're using a Lua
5.1 DLL (e.g. lua51.dll), you should define LUA_BUILD_AS_DLL when
building your extension. Finally, on all platforms, make sure you build
your extension with the same luaconf.h that was used to build Lua.
I hope these suggestions help. Of course, it would also be a good idea
to buy the second edition of PIL so you can learn to make the best use
of Lua 5.1's new features.
--
Matt Campbell
Lead Programmer
Serotek Corporation
www.freedombox.info
"The Accessibility Anywhere People"