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.06k stars 492 forks source link

SOL_BASE_CLASSES / SOL_DERIVED_CLASSES should be mentioned in the documentation #1597

Open Maddimax opened 2 months ago

Maddimax commented 2 months ago

I'm having the following project structure:

exe
  => lua-5.4.6 (static .lib)
  => lua-base (dynamic .dll) -> Includes sol and defines a bunch of usertypes with base/derived classes
      => class A;
      => class B : A;
  => SomePlugin (dynamic .dll) -> Provides some additional functions via sol (also includes sol.hpp), and uses the usertypes from lua-base

If "SomePlugin" now tries to call table.get<A>("example"), and in lua we did myTable["example"] = B::create(), the call of .get<A>(...)will fail as the check whether A is derived from B always fails.

As a workaround, adding SOL_DERIVED_CLASSES(A, B) and including that in "SomePlugin"'s code will fix the issue.

Therefore it would be great to mention this in the documentation, as finding it on your own is non-trivial :)