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.18k stars 515 forks source link

Fix build when LUA_COMPAT_BITLIB or LUA_COMPAT_5_2 are defined #1472

Closed lmoureaux closed 1 year ago

lmoureaux commented 1 year ago

Hi and thank you for sol2!

Lua may define the macros but leaves them empty. The code assumed they would contain a boolean value.

This is required to use sol2 with system Lua on Fedora 37 (see https://github.com/longturn/freeciv21/issues/1895)

Closes #1461.

llalonde1 commented 1 year ago

Is there an update on this?

ThePhD commented 1 year ago

I don't think this is a valid PR. I absolutely want to check if the value is defined to 0, and not act on it if it's defined to be 0. 0 means "off", not-0 means "on".

cuavas commented 1 year ago

You’re misunderstanding how Lua uses feature macros. As detailed in #1461, Lua does not define these macros to 0 or 1 to disable or enable the feature. The feature is enabled whenever the macro is defined at all, and src/luaconf.h defines LUA_COMPAT_BITLIB as an empty macro.

ThePhD commented 1 year ago

I'm in a bit of a bind, then, because some folk are using custom confs to explicitly shut it off by redefining it to be 0.... well.

Maybe this just means those folks will have to switch to agressive #undef. Hell if I know what's the right way anymore.

ThePhD commented 1 year ago

Either way, this is back to a way that'll work for everyone in this PR by way of this: https://github.com/ThePhD/sol2/commit/839f2a1dceb0c274d54ba755b2b508df3b7fdca5