lua-users home
lua-l archive

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


hi, i'm trying to learn to write a c extension module. i have a
working module, just have a few
questions.
my luaopen looks like this:

    // in lext.c
    int luaopen_lext(lua_State *L){
         luaL_openlib(L, "lext", lext, 0);
         return 1;
   }

and the lua wrapper like this.

    -- in lext.lua
    module(..., package.seeall)
    local f = assert(package.loadlib("./lext.so", "luaopen_lext"))
    return f()

is that the proper way to do this? i found that syntax for module() somewhere
but not sure if i should use that or module("lext") .
is there a good place for documentation on what the module(...) syntax means?

finally, i'm compiling with:

    gcc $(LUA_CFLAGS) -O2 -fPIC -o lext.o -c lext.c
    gcc -shared lext.o -o lext.so

is that reasonable?
thanks for any help. i know this information is available in various places, but
it's difficult to find all of it.

-brent