ThePhD / sol2

Sol3 (sol2 v3.0) - a C++ <-> Lua API wrapper with advanced features and top notch performance - is here, and it's great! Documentation:
http://sol2.rtfd.io/
MIT License
4.16k stars 508 forks source link

VS2022 ERROR C1202 #1341

Closed ImKK666 closed 2 years ago

ImKK666 commented 2 years ago

VS2022 X86

I have 100+ of binding functions


class GameObject
{
public:
    int a1;
    int a2;
    int a3;
......
    int a50;
//------
   GameObject *func1();
   int func2();
   bool func3();
......
   void func80();
};

sol::table GameObjectLua = lua.create_named_table("GameObject");
GameObjectLua.new_usertype<GameObject>("GameObject",
    "a1", &GameObject::a1,
    "a2", &GameObject::a2,
    "a3", &GameObject::a3,
......
    "a50", &GameObject::a50,

    "func1", &GameObject::func1,
    "func2", &GameObject::func2,
    "func3", &GameObject::func3,
......
    "func4", &GameObject::func4
    );

error:C1202 ..How to fix this bug?

OrfeasZ commented 2 years ago

Instead of binding all the methods / properties in the new_usertype call bind them individually using this syntax:

auto GameObjectUsertype = GameObjectLua.new_usertype<GameObject>("GameObject");
GameObjectUsertype["a1"] = &GameObject::a1;
GameObjectUsertype["a2"] = &GameObject::a2;
// etc