I am running Windows 7 (64 bit).
Using version 2014.2.0.0 of Haskell (64 and 32 bit).
With a 32-bit dll and a 32-bit Haskell program this works just fine.
With a 64-bit dll and a 64-bit Haskell program this does not work. Instead I get an access violation.
First-chance exception at 0x0000000000000000 in TestInterop.exe:
0xC0000005: Access violation executing location 0x0000000000000000.
c++ code (built as 64-bit dll):
BOOL __stdcall DllMain(HINSTANCE, DWORD, void*)
{
return TRUE;
}
extern "C" __declspec(dllexport) uint64_t ReverseDigits(uint64_t number)
{
uint64_t result = 0;
while (number)
{
result *= 10;
result += number % 10;
number /= 10;
}
return result;
}
The Haksell code
module Main where
import Foreign.C
foreign import ccall unsafe "ReverseDigits" interopReverseDigits :: CULLong -> IO CULLong
main = do
x <- interopReverseDigits(1234)
if x == 4321
then putStrLn "Successfully Called Test"
else putStrLn "Call to test failed"</code></pre>
Is there some sort of special thunk I need to perform in Haskell for this to work?