
29 Mar
2009
29 Mar
'09
10:14 a.m.
Hi, I'm trying to have hsc2hs interpret this snippet that picks a calling convention to use for FFI imports: #if !defined(CALLCONV) #ifdef WITH_WINSOCK #define CALLCONV stdcall #else #define CALLCONV ccall #endif #endif foreign import CALLCONV unsafe "send" c_send :: CInt -> Ptr a -> CSize -> CInt -> IO CInt Compiling results in: parse error on input `CALLCONV' Inspecting the generated .hs file shows that CALLCONV appear in the source code instead of being replaced with either stdcall or ccall as expected. What's the correct way to use #define in .hsc files? Changing the file extension to .cpphs solves the problem, by using plain CPP instead of hsc2hs I presume. Cheers, Johan