lua-users home
lua-l archive

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


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

Thanks,
Antonio

> Date: Wed, 30 Nov 2011 17:05:54 +0100
> From: Mike Pall <mikelu-1111@mike.de>
> Subject: Re: Detecting LuaJIT at compile time
> To: Lua mailing list <lua-l@lists.lua.org>
> Message-ID: <20111130160554.GA4608@mike.de>
> Content-Type: text/plain; charset=us-ascii
>
> Antonio Vieiro wrote:
>> Is it possible to know if I'm compiling with LuaJIT at compile time?
>> (this is, is there any #define out there specifically for detecting
>> LuaJIT?).
>
> Any C module you build against the Lua headers runs under LuaJIT
> or vice versa (and the headers are almost the same). Even if you
> build it with one set of headers, you can still load the same
> binary module into the other VM.
>
> So static detection at compile time (e.g. by some artifact in the
> headers) simply doesn't do what you think it might do.
>
> --Mike
>
>
>
> ------------------------------
>
> _______________________________________________
> lua-l mailing list
> lua-l@lists.lua.org
> http://vlists.pepperfish.net/cgi-bin/mailman/listinfo/lua-l-lists.lua.org
>
>
> End of lua-l Digest, Vol 16, Issue 131
> **************************************