First of all, I am using these versions, installed via vcpkg:
Lua version 5.4.4
sol2 version 3.3.0
I seem to have trouble assigning union members to usertypes.
The compiler produces an error, suggesting that I might be trying to bind members to an unrelated class.
Are "raw" unions simply not a thing in Lua/sol2? I'm sorry if it's stated somewhere, I couldn't find any information about it.
Here is the error message:
It seems like you might have accidentally bound a class type with a member function method that does not correspond to the class. For example, there could be a small type in your new_usertype(...) binding, where you specify one class "T" but then bind member methods from a complete unrelated class. Check things over!
Here is a simple main.cpp to reproduce the issue:
#include <sol/sol.hpp>
struct S {
int i;
char c[4];
};
union U {
int i;
char c[4];
};
int main()
{
sol::state lua;
// Test with struct
sol::usertype<S> struct_type = lua.new_usertype<S>("S");
struct_type["i"] = &S::i;
struct_type["c"] = &S::c;
// Test with union
sol::usertype<U> union_type = lua.new_usertype<U>("U");
union_type["i"] = &U::i; // <--- Compiler error
union_type["c"] = &U::c; // Never reached
}
Same happens trying directly from the new_usertype() function:
Greetings,
First of all, I am using these versions, installed via vcpkg:
I seem to have trouble assigning union members to usertypes. The compiler produces an error, suggesting that I might be trying to bind members to an unrelated class. Are "raw" unions simply not a thing in Lua/sol2? I'm sorry if it's stated somewhere, I couldn't find any information about it.
Here is the error message:
Here is a simple
main.cpp
to reproduce the issue:Same happens trying directly from the
new_usertype()
function:Thanks in advance for the help.