sol2 icon indicating copy to clipboard operation
sol2 copied to clipboard

SOL_BASE_CLASSES / SOL_DERIVED_CLASSES should be mentioned in the documentation

Open Maddimax opened this issue 10 months ago • 0 comments

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 :)

Maddimax avatar Apr 15 '24 13:04 Maddimax