I am trying to register a c++ function in Lua.
But getting this error:
CScript.cpp|39|error: argument of type \'int (CScript::)(lua_State*)\' does n
You cannot directly register a C++ non-static member function in Lua using just the basic Lua C API.
However, any of the various mechanisms that exist for easily associating C++ code with Lua will allow you to do so. toLua++, SWIG, Luabind, etc. If you're serious about using C++ objects with Lua, I suggest picking one of those and using it, rather than writing your own version. I personally use Luabind (most of the time; SWIG has its place in the toolbox), as it is the one that doesn't have some form of code generation. It's all done purely in C++, so there's no pre-pass step that generates a C++ source file.