At 09:48 2-2-2010 -0800, Tim Mann wrote:
That's odd; I thought %I64 was only used by the Microsoft C library.
Maybe with -mno-cygwin, gcc is linking scanf to a version from the
Microsoft runtime library? Just as an experiment, what happens if you
do use the Cygwin library (i.e., don't give -mno-cygwin)?
Indeed, without the -mno-cygwin flag, the test program I made worked fine:
h...@chess_laptop /home/fboard/xboard-4.4.1/winboard
$ cat test.c
#include <stdio.h>
main()
{
unsigned long long int t;
t = ~0;
printf("low word = %08x, high word = %08x\n", t);
printf("%llu %d %d %d\n", t, 1, 2, 3);
sscanf("23", "%llu", &t);
printf("low word = %08x, high word = %08x\n", t);
printf("%llu %d %d %d\n", t, 1, 2, 3);
}
h...@chess_laptop /home/fboard/xboard-4.4.1/winboard
$ gcc -mno-cygwin test.o -o test.exe
h...@chess_laptop /home/fboard/xboard-4.4.1/winboard
$ ./test
low word = ffffffff, high word = ffffffff
4294967295 -1 1 2
low word = 00000017, high word = ffffffff
23 -1 1 2
h...@chess_laptop /home/fboard/xboard-4.4.1/winboard
$ gcc test.o -o test.exe
h...@chess_laptop /home/fboard/xboard-4.4.1/winboard
$ ./test
low word = ffffffff, high word = ffffffff
18446744073709551615 1 2 3
low word = 00000017, high word = 00000000
23 1 2 3
The compiler warnings probably need to be fixed by using the correct
variable types. I'm surprised they aren't bugs... however, I haven't
seen the actual warnings so I don't really know what the problem is
there.
The warnings are these:
$ make -f makefile.gcc
../backend.c
../backend.c: In function `HandleMachineMove':
../backend.c:7423: warning: unsigned int format, different type arg (arg 7)
../backend.c:7548: warning: unsigned int format, different type arg (arg 4)
../backend.c:7611: warning: unsigned int format, different type arg (arg 7)
In relation to Eric's explanation:
Would it not be a solution to make the definition dependent on USE_MINGW,
which we define in the makefile.gcc anyway, and which also switches the use
of the -mno-cygwin option on? E.g. put something in the makefile like
# set up for cygwin or not
ifeq ($(USE_MINGW),1)
CFCYG = -mno-cygwin -DUSE_I64
LFCYG = -mno-cygwin -lmsvcrt
endif
so that we could use an #ifdef USE_I64 to choose between "%llu" and "%I64u"
in backend.h?
_______________________________________________
Bug-XBoard mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-xboard