Current-Users archive

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

LLONG_MAX not available from c++



Hi!

mame wants to compile lua with a c++ compiler.[1]

lua has a check in its headers to detect C99 mode by looking for
LLONG_MAX. If that is not found (and no workaround like an explicit
fallback to 32-bit ints is defined) then it fails to compile.

g++ in -current doesn't get this symbol when you include limits.h
(which lua does, since this is still C code) because of (from
/usr/include/machine/limits.h):

#if defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) >= 199901L || \
    defined(_NETBSD_SOURCE)
#define ULLONG_MAX      0xffffffffffffffffULL   /* max unsigned long long */
#define LLONG_MAX       0x7fffffffffffffffLL    /* max signed long long */
#define LLONG_MIN       (-0x7fffffffffffffffLL-1) /* min signed long long */
#endif

What is the best solution here?

1. define LUA_32BITS to use short ints?

2. pass a magic define to the compiler so the header works better when
used from c++? (which one would that be, _NETBSD_SOURCE?)

3. change the installed header in some way (but that won't help NetBSD
8/9/10)

Suggestions welcome!
 Thomas


[1] https://www.mamedev.org/ says: The technical reason for this
change is that MAME requires C++ stack frames to be unwound correctly,
including destructor calls, when Lua errors are raised from C++
code. Using Lua compiled as C will cause resource leaks.


Home | Main Index | Thread Index | Old Index