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

issues with clang and registerFunction - probably clang's fault #21

Open
ahupowerdns opened this issue Feb 15, 2015 · 1 comment
Open
Labels

Comments

@ahupowerdns
Copy link
Contributor

Many thanks for Luawrapper, it is amazing, and over at PowerDNS we plan to do big things with it. However, we ran into a snag.
Now this is probably due to clang 3.5 (OSX Yosemite) being wrong. I think it deducts that the function passed is const, which it is not.

Any use of registerFunction on an object errors out with:
./ext/luawrapper/include/LuaContext.hpp:1050:172: error: no matching function for call to object of type 'const std::__1::_mem_fn<void (Object::)()>'
setTable<TRetValue(TObject
, TOtherParams...)>(mState, Registry, &typeid(TObject
), 0, functionName, [=](TObject* obj, TOtherParams... rest) { assert(obj); return function(_obj, std::fo...
^~~~~~~~
./ext/luawrapper/include/LuaContext.hpp:1071:9: note: in instantiation of function template specialization 'LuaContext::registerFunctionImpl<std::__1::__mem_fn<void (Object::)()>, void,
Object>' requested here
registerFunctionImpl(functionName, std::move(function), tag{}, tag<TRetValue (TOtherParams...)>{});
^
./ext/luawrapper/include/LuaContext.hpp:350:9: note: in instantiation of function template specialization
'LuaContext::registerFunctionImpl<std::__1::__mem_fn<void (Object::
)()>, void, Object>' requested here
registerFunctionImpl(name, std::mem_fn(pointer), tag{});
^
los.cc:17:7: note: in instantiation of function template specialization 'LuaContext::registerFunction<void (Object::)()>' requested here
lua.registerFunction("increment", &Object::increment);
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/functional:1224:11: note: candidate function not viable: 'this' argument has type
'const std::__1::__mem_fn<void (Object::
)()>', but method is not marked const
operator() (_ArgTypes&&... __args)
^
In file included from los.cc:1:
./ext/luawrapper/include/LuaContext.hpp:1053:227: error: no matching function for call to object of type 'const std::__1::__mem_fn<void (Object::*)()>'
...Registry, &typeid(std::shared_ptr), 0, functionName, [=](const std::shared_ptr& obj, TOtherParams... rest) { assert(obj); return function(obj, std::forward<TOtherPara...
^~~~~~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/functional:1224:11: note: candidate function not viable: 'this' argument has type
'const std::__1::__mem_fn<void (Object::
)()>', but method is not marked const
operator() (_ArgTypes&&... __args)

This when compiling:
class Object {
public:
Object() : value(10) {}
void increment() { std::cout << "incrementing" << std::endl; value++; }
int value;
};

int main()
{
LuaContext lua;
lua.registerFunction("increment", &Object::increment);
}

I tried a lot of thing to work around this issue, but short of deleting the registration of the pointer and shared_ptr versions, I can't find anything..

Help ;-)

@tomaka tomaka added the bug label Feb 15, 2015
@n1xx1
Copy link

n1xx1 commented May 10, 2015

Same issue here.

Habbie added a commit to PowerDNS/luawrapper that referenced this issue Mar 24, 2017
luajit: link binaries with necessary flags on osx
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

3 participants