lua-users home
lua-l archive

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

>> To test c89 compatibility, i wanted to compile lua 5.4.4 on a very
>> old version  of MSVC. The compiler complains about the line 270 of
>> lmathlib.c "#if (ULONG_MAX>>31>>31)>=3" with "Fatal error C1012:
>> unmatched parenthesis: missing ')'". Is this caused by
>> non-conformance to c89 of the new random generator code or is this
>> just a compiler bug ?

Does your MSVC have anything akin to the usual-on-Unices -E option, to
let you look at the preprocessor output?  I'm wondering if ULONG_MAX is
mis-defined somehow.  You can't tell just by looking at preprocessor
output, because this is happening in a #if line, but if you add a line
just above, something like
static int test_var = ULONG_MAX;
and search the preprocessor output for test_var, you may see something

You might also try ((ULONG_MAX>>31)>>31) instead of
(ULONG_MAX>>31>>31).  They _should_ be equivalent, but....

I recently did a build of 5.4.4 myself on a system with egcs-1.1.2 and
found I had to do a bit of bludgeoning here and there; the similar line
some ten lines later (with LUA_MAXUNSIGNED) was one of them.  In my
case, well, here's the result of my bludgeoning:

 * I've been unable to figure out how to avoid getting
 *      "lmathlib.c", line 280: warning: integer constant out of range
 *  for this on 1.4T.  So, ugly as it is, we hardwire the knowledge
 *  that all systems this patch tree will be used on have 64-bit
 *  integers.
/* #elif (LUA_MAXUNSIGNED >> 31 >> 31) >= 3 */
#elif 1

(I'm actually not sure whether it would have compiled the correct code
anyway; I use -Werror, and considered the above patch preferable to
dropping -Werror.  I can share the rest of my patches too if anyone is

/~\ The ASCII				  Mouse
\ / Ribbon Campaign
 X  Against HTML
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B