   Problem registering a function with lua.
  I'm trying to registering a function with lua but it keeps giving me this error:"error C2664: 'luaL_register' : cannot convert parameter 3 from 'int (__cdecl *)(lua_State *)' to 'const luaL_Reg *'1>   There is no context in which this conversion is possible"I'm was following a tutorial, here is how I understand this should work:static int l_myfunc(lua_State *L){return 1;}void runcode(){    lua_State *L = lua_open(); luaL_openlibs(L);luaL_register( L, "myfunc", l_myfunc );    luaL_dofile(L,"test.lua"); lua_close(L);}What am I doing wrong?   
  from the code that I posted does anyone see a problem with it?   ;  You're registering a library, not a function.The registration routines were changed a bit though, you might want to look through function signatures.   ;  luaL_register is for registering a group of functions (as in building a library), not a single function.  Depending on what you are trying to do you can use luaL_register, or you could just push the C function pointer on the stack, then push a name for the function.  Here's some example code (straight from the online programming in Lua book @ http://www.lua.org/pil/26.1.html )//your wicked fast functionstatic int l_sin (lua_State *L) {   double d = lua_tonumber(L, 1);  /* get argument */   lua_pushnumber(L, sin(d));  /* push result */   return 1;  /* number of results */}//somewhere in your initialization codelua_pushcfunction(l, l_sin);lua_setglobal(l, "mysin");//in your Lua Scriptans=mysin(1.0)Cheers, Bob   ;Quote:Original post by EmptyVoidfrom the code that I posted does anyone see a problem with it?In future can you wait longer than just under an hour before bumping your own topics.   ;Quote:Original post by phantomQuote:Original post by EmptyVoidfrom the code that I posted does anyone see a problem with it?In future can you wait longer than just under an hour before bumping your own topics.OK Phantom you can close it now, if you want... Thanks Scourage!   ;  No need to close the thread, but please mark it SOLVED so other uses may find an answer they need.cheers, Bob   ;  No, please don't mark it solved: we don't do that here. This isn't a support forum but a discussion forum, and threads are open for continued discussion long after the original poster may have found what they want.   