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.12k stars 500 forks source link

LuaJIT 2.1.0-beta3 and 64-bit bitwise operations #1436

Closed vdweller84 closed 1 year ago

vdweller84 commented 1 year ago

Hello,

My apologies in advance if this is not a SOL issue but I thought it'd be worth asking. I have encountered the following issue: I am trying to use luaJIT's built-in bit library which, reportedly, handles 64-bit integers. The issue is: When I try to use local bit = require("bit") and do my thing, I get this error:

ERROR! XElua_state.cpp : 352 : CheckAndRunFunction : Assets/script/__init.lua:1: module 'bit' not found:
        no field package.preload['bit']
        no file '.\bit.lua'
        no file 'C:\Users\User\source\repos\engine\x64\Debug\lua\bit.lua'
        no file 'C:\Users\User\source\repos\engine\x64\Debug\lua\bit\init.lua'
        no file '.\bit.dll'
        no file 'C:\Users\User\source\repos\engine\x64\Debug\bit.dll'
        no file 'C:\Users\User\source\repos\engine\x64\Debug\loadall.dll'

Opening sol::lib::bit32 makes bit functions work but only for 32-bit numbers.

So...is there any way to make the "correct" luaJIT library visible?

C3pa commented 1 year ago

Are you sure that LuaJIT's Bitop module works with 64-bit integers? Isn't Mike Pall against the drawbacks that the Lua 5.3 implementation of 64-bit integers introduced?

Now, looking at the BitOps docs:

Note that all bit operations return signed 32 bit numbers (rationale). And these print as signed decimal numbers by default.

Source

And:

It's desirable to define semantics that work the same across all platforms. This dictates that all operations are based on the common denominator of 32 bit integers.

Source

Correct me if I am not talking about the same module.