lua-users home
lua-l archive

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


Am 03.12.2013 02:17 schröbte Lourival Vieira Neto:
On Mon, Dec 2, 2013 at 6:22 PM, Philipp Janda <siffiejoe@gmx.net> wrote:
Am 02.12.2013 20:55 schröbte Lourival Vieira Neto:

Simple answer: int64_t is C99, Lua tries to stay compatible with C89.



... and although "long long" is not in C90 either, it was implemented as
an
extension by many C90 compilers (and C++, I believe) before the C99
standard
was defined. Also, "long long" is not required to be 64 bits wide (but it
is
at least as wide as a "long"). "ptrdiff_t" on the other hand *is* in C90
and
has a good chance to be 64 bits on a machine that supports 64 bit
addresses.


Just making it clearer.. Lua 5.3 uses long long instead of ptrdiff_t
for lua_Integer, by default.


Makes sense. "long long" has a much higher chance of being 64 bits on 32 bit
machines, and having 64 bit integers becomes important in Lua 5.3.

In fact, my question was: why don't use int64_t instead? Once it
always has 64 bit width.

Because you need to include "stdint.h" for that, and you cannot reliably check for the existence of header files from within C. `int64_t` is optional in C99, btw, so if `long long` isn't at least 64 bits on your machine, you probably won't have `int64_t` either. MS Visual C was one of the more popular C90 compilers that didn't have "stdint.h", more recent versions do have it though, so maybe it's time ...


Regards,


Philipp