Closed RobbinMarcus closed 6 months ago
@RobbinMarcus Have you had success with lua itself only (no sol)?
Yes, running Emscripten with various distributions of Lua has worked out great so far!
Specifically for this issue: Passing values back and forth using the global table (or tables on there) works.
I also tested similar functionality using LuaBridge3 which was able to register members using the .addProperty("x", &class:x)
.
Hmm, my guess is that the noexcept here https://github.com/ThePhD/sol2/blob/9c882a28fdb6f4ad79a53a4191b43ce48a661175/include/sol/function_types_stateless.hpp#L363C33-L363C41 is the problem.
However, if I understand correctly, it should not be a problem in Cpp17 (link). Emphasis mine.
Pointers (including pointers to member function) to non-throwing functions can be assigned to or used to initialize(until C++17)are implicitly convertible to(since C++17) pointers to potentially-throwing functions, but not the other way around.
So maybe it is a problem in the compiler toolchain not supporting this? Maybe you can just try casting or removing the noexcept to see how it works?
Thank you so much for that! Removing the noexcept on lines 363 and 323 in function_types_stateless
(both call
functions) allowed it to return the correct function call for emcc, thus compiling once again on my side.
This solves my problem so I'll close this issue. I haven't run into any issues using any other Sol2 functionality so far on Emscripten (after some brief test runs), so if anyone is thinking about this combo be sure to give it a try with the changes mentioned above!
Compiling this simple example for emscripten:
Results in the following error:
I'm hoping you could help me out with some suggestions. I've tried the following:
-frelaxed-template-template-args
compiler flags for clang. This seems to have no effect.template<T>
tousing template_t = template<T>
. I tried a couple of these but I'm in over my head and it seemed to have no effect either.Reproducing:
Combine them using this cmake file:
Then build for emscripten (using their sdk for emcmake) using:
EMCC version:
Edit: for anyone trying to use properties like above: the example compiles, but it's not functional. I have found no workaround other than polymorphism to add property functions to the type.