lua-users home
lua-l archive

Re: Is it possible to send var-args (...) to a native function?

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Monday 07 February 2011 17:33:33 Sean Conner wrote:
> It was thus said that the Great Luiz Henrique de Figueiredo once stated:
> > Try the code below and then compare to your own.
> 
> 32 bit Linux, Lua 5.1.4 (with all the patches [1]) and the following C
> code:
> 
> 
> #include <stdio.h>
> #include <lua.h>
> 
> static int construct(lua_State *L)
> {
> int stack_size;
> 
> stack_size = lua_gettop(L);
> printf("construct %d items in stack\n",stack_size);
> lua_pushinteger(L,stack_size);
> return 1;
> }
> 
> int luaopen_construct(lua_State *L)
> {
> lua_register(L,"construct",construct);
> return 0;
> }
> 
> [spc]lucy:~/source/lua/C>gcc -shared -fPIC -o construct.so construct.c
Why the -shared and the -fPIC? Are they necessary? I was able to get a similar 
program to work without them.
Thanks
SteveT
Steve Litt
Recession Relief Package
http://www.recession-relief.US
Twitter: http://www.twitter.com/stevelitt

AltStyle によって変換されたページ (->オリジナル) /