lua-users home
lua-l archive

Re: about lposix

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


On 18/10/2006, at 11:21 AM, Mike Pall wrote:
To use the Cygwin-provided toolchain, you need -mno-cygwin *and*
the mingw target. You can do this without changing the Makefile:
 make "CC=gcc -mno-cygwin" mingw
Or just build Lua using plain MinGW with: make mingw
Sorry if this is getting a bit off-topic, but here goes ...
That works fine, and I get a dll that doesn't require cygwin1.dll. But ...
I amended luaconf.h to add this line:
#define LUA_USELONGLONG
Now, when compiled, and I try this:
print (string.format ("%i", 2^62)) --> should be: 4611686018427387904, but is: 0
A quick test using this program has some interesting results:
-------------
#include <stdio.h>
int main (void)
 {
 long long x = 4611686018427387904LL;
 printf ("%lld", x);
 return 0;
 }
-------------
If I compile this like so: gcc test.c -o test
And test it: ./test
I get this: 4611686018427387904
But, if I compile like this: gcc test.c -mno-cygwin -o test
And test it: ./test
I get this: 0
Internally Lua is using the %lld format to do a string.format (if you have LUA_USELONGLONG defined) so the problem with my test program is what is causing the problem with Lua. How do I compile and link, without needing the cygwin1.dll library, but still getting the correct "long long" functionality?
- Nick

AltStyle によって変換されたページ (->オリジナル) /