Original Post
Hi, Im trying to export some functions from a class to lua but there seems to be some kind of problem that I do not understand. Heres a code snippet #include ".\LUA\lua.h" #include ".\LUA\lauxlib.h" #include ".\LUA\lualib.h" lua_State * mLuaState; class test { public: test() {} ~test() {} int testfunction (lua_State * tluastate) { return 1; } }; typedef int (test::*lua_CFunction)(lua_State *); void main (void) { test mytest(); lua_CFunction fp = test::testfunction; lua_register(mLuaState, "testfunc", fp); } Well.... I declared the function pointer like how the function pointer should be declared. I get an error like this: error C2373: 'lua_CFunction' : redefinition; different type modifiers error C2440: 'initializing' : cannot convert from 'int (__thiscall test::* )(lua_State *)' to 'lua_CFunction' None of the functions with this name in scope match the target type I do not understand why am I getting this error. I tried exporting a global function and it work but when i tried the above it doesn't. Is it that lua_register does not support exporting of class functions or did i miss out something that will make it work. PS: Im new with posting codes in this forums and would appreciate if someone can tell me how to encase codes within a tag. Thanks