lua-users home
lua-l archive

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


FAO Bradley
 
Thank you very much for clarifying the code and script which I have amended accordingly.
 
Interestingly, the use of NULL in the registration follows comments earlier which suggested that it made revision of the name of the library easier as only additional functions need to be added and the version name updated to be effective.  The use of "mylib" whilst certainly workable was therefore specific to the name of the library.  However, as before I am grateful for your comments and the time taken to write.
 
C



Bradley Smith <gmane@baysmith.com> wrote:
Alternatively, change mylib.c from:

LUALIB_API int luaopen_mylib (lua_State *L){
lua_newtable(L);
luaL_register(L, NULL, mylib);
return 1;
}

to:

LUALIB_API int luaopen_mylib (lua_State *L){
luaL_register(L, "mylib", mylib);
return 1;
}

and use the following script:

#!/usr/bin/env lua

package.cpath = "./?.so;" .. package.cpath
require("mylib")
print "\nHello World\n"
-- call a C function and send a number
local indicator = mylib.prin(1)
print("The result is ", indicator)




__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com