Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile error on .addConstructor(LUA_ARGS(_opt<std::string>)) #2

Closed
rvt opened this issue Apr 7, 2014 · 4 comments
Closed

Compile error on .addConstructor(LUA_ARGS(_opt<std::string>)) #2

rvt opened this issue Apr 7, 2014 · 4 comments
Labels

Comments

@rvt
Copy link

rvt commented Apr 7, 2014

Hey,

I am getting the below compile error.
What could be the cause of it?
I did add the lib as headers only, but also tried compiling as cpp.

Ries

In file included from ./lua-intf/LuaIntf.h:27:
In file included from ./lua-intf/LuaIntf/LuaIntf.h:32:
In file included from ./lua-intf/LuaIntf/LuaContext.h:32:
./lua-intf/LuaIntf/LuaRef.h:1098:36: warning: unused parameter 'L' [-Wunused-parameter]
    static void pushArg(lua_State* L)
                                   ^
In file included from cad/lualibrecadbridge.cpp:6:
In file included from ./lua-intf/LuaIntf.h:27:
In file included from ./lua-intf/LuaIntf/LuaIntf.h:40:

..
..
./lua-intf/LuaIntf/impl/CppInvoke.h:236:32: warning: unused parameter 'L' [-Wunused-parameter]
    static int push(lua_State* L, T* t, const FN& func, std::tuple& args)
                               ^
cad/lualibrecadbridge.cpp:26:25: error: type name requires a specifier or qualifier
        .addConstructor(LUA_ARGS(_opt))
                        ^
./lua-intf/LuaIntf/impl/CppArg.h:49:35: note: expanded from macro 'LUA_ARGS'
#define LUA_ARGS(...) static_cast(nullptr)
                                  ^
./lua-intf/LuaIntf/impl/CppArg.h:48:28: note: expanded from macro 'LUA_ARGS_TYPE'
#define LUA_ARGS_TYPE(...) _arg(*)(__VA_ARGS__)
                           ^
cad/lualibrecadbridge.cpp:26:25: error: expected '>'
./lua-intf/LuaIntf/impl/CppArg.h:49:35: note: expanded from macro 'LUA_ARGS'
#define LUA_ARGS(...) static_cast(nullptr)
                                  ^
./lua-intf/LuaIntf/impl/CppArg.h:48:28: note: expanded from macro 'LUA_ARGS_TYPE'
#define LUA_ARGS_TYPE(...) _arg(*)(__VA_ARGS__)
                           ^
cad/lualibrecadbridge.cpp:26:25: note: to match this '<'
./lua-intf/LuaIntf/impl/CppArg.h:49:34: note: expanded from macro 'LUA_ARGS'
#define LUA_ARGS(...) static_cast(nullptr)
                                 ^
7 warnings and 2 errors generated.
make: *** [generated/obj/lualibrecadbridge.o] Error 1
@SteveKChiu
Copy link
Owner

VA_ARGS does not expand correctly. Can you post the compile command line? It is more like you forget to enable some flags.

@rvt
Copy link
Author

rvt commented Apr 8, 2014

Hey Steve,

I figured out what the reason was, I had to use using namespace LuaIntf; in my code rather then using LuaIntf::LuaBinding(L), so now it's all working fine.

I do have a other question if you don't mind:

I am using boost I'm my application and noticed that the function LuaCppObjectFactory uses static cast, however I believe with boost you need to use static_pointer_cast. so I hacked it and changed it to : return boost::static_pointer_cast<CppObjectSharedPtr<SP, T>>(obj)->sharedPtr();

That seem to work fine, any suggestions for a proper fix? I was thinking to do something like
LUA_USING_STATIC_CAST_TYPE(boost::static_pointer_cast) but I am not sure if that's truly the right solution as my daily work isn't c++ but java.

@SteveKChiu
Copy link
Owner

No, it is not necessary, the original code works fine. boost::static_pointer_cast (and std::static_pointer_cast) is to cast shared_ptr<T> to shared_ptr<U>, and LuaIntf don't do that kind of casting.

However, I do find a bug in the static_cast of the following line:

        return static_cast<CppObjectSharedPtr<SP, T>>(obj)->sharedPtr();

should be:

        return static_cast<CppObjectSharedPtr<SP, T>*>(obj)->sharedPtr();

ah, miss a '*'. I really need to add more testing, I will add them later.

@rvt
Copy link
Author

rvt commented Apr 9, 2014

Hello Steve,

thanks for taking a look at this and tomorrow morning I am going to take a second look at the change I made and see if I can go without the change I made.

Currently I have everything working with your library, and the use of shared pointer's , this is the code I am currently working on : https://github.com/rvt/kerneldev/blob/master/lcadluascript/cad/lualibrecadbridge.cpp

Background, I am working on a new version of LibreCAD and with lua scripting we can start testing functionality without adding UI functionality by simply scripting it.

SteveKChiu added a commit that referenced this issue Apr 9, 2014
@SteveKChiu SteveKChiu added the bug label Jul 28, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants