lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Antonio Vieiro wrote:
> I just want to print out the version of Lua I'm using, something like this:
> 
> #ifdef _SOME_VAR_TO_DETECT_LUAJIT
>   #include <luajit.h>
>    fprintf(stderr, "Using LuaJIT version %s for Lua %s\n",
> LUAJIT_VERSION, LUA_RELEASE);
> #else
>    fprintf(stderr, "Using Lua version %s\n", LUA_RELEASE);
> #endif
> 
> Of course I could add a variable myself to specify if I'm compiling
> with Lua or with LuaJIT, but I'd prefer not to add that extra variable
> (because, as you say, there's total compatibility between Lua and
> LuaJIT headers, so setting CFLAGS and LDFLAGS should be enough in my
> Makefile).

I don't think you understood what I said. Your code may still be
running under either Lua or LuaJIT. It only depends on which
library you link against and/or from which VM your module is
loaded. The C compiler cannot know that. You definitely want to
print the version info provided at runtime, not a static version.

--Mike