Search code examples
lua32bit-64bit

Determine whether Lua compiler runs 32 or 64 bit


I am currently using Windows on my default development system and Linux on my server where I deploy my Lua scripts. For Windows there are only several 32 bit interpreters like Lua for Windows one I currently use (at least as far as i know). On the server the interpreter is running the scripts on 64 bits.

Now my question is: Is it possible to check on which architecture the script is running (probably similar to the _ENV variable for the version)?

If there is any 64 bit Windows Lua interpreter feel free to leave a comment on this matter. Thank you in advance.


Solution

  • If you can get the executable that runs the script, you can probably look at its header on Windows and Linux to check if it's 32bit or 64bit application; here are suggestions on how to do it on Windows.

    I'm also interested in simpler ways to do it from a Lua script (and the one that works with Lua and LuaJIT interpreters), as I ran into a case when I'd like to reference different paths depending on whether 32bit or 64bit library needs to be loaded without the user having to specify those paths.