nbind
nbind copied to clipboard
nbind::cbOutput failed to compile
It's quite weird, because it does compile on the repository I shared with you earlier, but doesn't on this one: https://github.com/arcanis/text-layout Despite the code being almost identical (https://github.com/arcanis/text-layout/blob/master/sources/Position.hh#L41-L44 vs https://github.com/arcanis/buffer-offset-index/blob/master/src/point.h#L34-L36)
I've double-checked everything for the past few hours, and dived into nbind's headers, but I've failed to completely understand the issue. Apparently, the compiler fails to find a proper BindingType<CreateValue>
specialization - which makes little sense, since a very similar toJS
function does work on the other repository ...
The error message is the following:
make: Entering directory '/home/arcanis/text-formatter/build'
CXX(target) Release/obj.target/nbind/sources/nbind.o
CXX(target) Release/obj.target/nbind/sources/TextLayout.o
In file included from ../sources/TextLayout.cc:9:
In file included from ../node_modules/nbind/include/nbind/api.h:93:
../node_modules/nbind/include/nbind/em/Callback.h:69:17: error: assigning to 'int' from incompatible type 'typename BindingType<CreateValue>::Type' (aka 'nbind::cbOutput::CreateValue')
original.slot = jsConstructor.call<CreateValue>(args...);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../sources/./Position.hh:43:15: note: in instantiation of function template specialization 'nbind::cbOutput::operator()<const unsigned int &, const unsigned int &>' requested here
output(x, y);
^
In file included from ../sources/TextLayout.cc:9:
In file included from ../node_modules/nbind/include/nbind/api.h:93:
../node_modules/nbind/include/nbind/em/Callback.h:28:9: error: no viable conversion from returned value of type 'int' to function return type 'typename BindingType<CreateValue>::Type' (aka 'nbind::cbOutput::CreateValue')
return(Caller<ReturnType>::call(handle.getNum(), std::forward<Args>(args)...));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../node_modules/nbind/include/nbind/em/Callback.h:69:33: note: in instantiation of function template specialization 'nbind::cbFunction::call<nbind::cbOutput::CreateValue, const unsigned int &, const unsigned int &>' requested here
original.slot = jsConstructor.call<CreateValue>(args...);
^
../sources/./Position.hh:43:15: note: in instantiation of function template specialization 'nbind::cbOutput::operator()<const unsigned int &, const unsigned int &>' requested here
output(x, y);
^
../node_modules/nbind/include/nbind/em/Callback.h:57:9: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'int' to 'const nbind::cbOutput::CreateValue &' for 1st argument
struct CreateValue {};
^
../node_modules/nbind/include/nbind/em/Callback.h:57:9: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'int' to 'nbind::cbOutput::CreateValue &&' for 1st argument
struct CreateValue {};
^
2 errors generated.
ERROR:root:compiler frontend failed to generate LLVM bitcode, halting
It's apparently an header issue - I've manually included nbind/BindDefiner.h
, and it compiled.
I was seeing the same issue and the suggestion above about manually including nbind/BindDefiner.h
solved the problem for me too.