[Haskell-cafe] Problem using #define in .hsc files

Johan Tibell johan.tibell at gmail.com
Sun Mar 29 10:14:08 EDT 2009


I'm trying to have hsc2hs interpret this snippet that picks a calling
convention to use for FFI imports:

#if !defined(CALLCONV)
#define CALLCONV stdcall
#define CALLCONV ccall

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.



More information about the Haskell-Cafe mailing list