Passing 64-bit int to DLL problem
Posted: Mon Jul 02, 2007 7:59 pm
I'm having trouble with passing 64-bit integers to DLL functions. The DLL is compiled on Windows XP using MinGW, and used with newLISP v9.1.1.
Here is a test program that shows the problem:
test64.c
test64.def
make.bat
test64.lsp
Output:
32-bit integers pass without a problem, but I can't seem to get the most significant integer of the 64-bit number.
Here is a test program that shows the problem:
test64.c
Code: Select all
#include <stdio.h>
__declspec (dllexport) int Test64(__int64 i)
{
unsigned int * pi;
pi = (unsigned int*)&i;
printf("0x %08X %08X", pi[1], pi[0]);
return 0;
}
Code: Select all
LIBRARY TEST64.DLL
EXPORTS
Test64 @1 Test64
Code: Select all
C:\MinGW\bin\mingw32-gcc test64.c -c -Wall
C:\MinGW\bin\dllwrap.exe test64.o --enable-stdcall-fixup -def test64.def -o test64.dll
Code: Select all
(import "test64.dll" "Test64")
(setq test-values
'(0x0000000087654321
0x000000A987654321
0x0000CBA987654321))
(dolist (val test-values)
(println (dump val))
(println (format "0x %08X %08X"
(get-int (+ 4 (address val)))
(get-int (address val))
))
(Test64 val)
(println)(println)
)
(exit)
Code: Select all
(218736 898 212400 -2023406815 0)
0x 00000000 87654321
0x 000356D0 87654321
(218736 898 212400 -2023406815 169)
0x 000000A9 87654321
0x 000356F0 87654321
(218736 898 212400 -2023406815 52137)
0x 0000CBA9 87654321
0x 000356D0 87654321