I'm trying to write a quick binding to some ioctl functions (in particular, getting and setting the window size) using c2hs. Here's the relevant part of what I have:
{-# LANGUAGE ForeignFunctionInterface #-}
#include <sys/ttycom.h>
#include <sys/ioctl.h>
module A where
import Foreign.Storable
import Foreign.Ptr
import Foreign.C
{#enum define TIO {TIOCGWINSZ as GetWinsz, TIOCSWINSZ as SetWinsz} deriving (Eq) #}
(full code available at https://gist.github.com/nc6/8977936)
When I try to compile this, I get:
c2hs: Feature not yet implemented: GenBind.evalConstCExpr: Casts are not implemented yet.
I'm guessing the cause of this problem is that the C consts are defined using some helper functions (_IOW
and _IOR
) which the Haskell preprocessor is unable to deal with. However, it's not clear how best to fix this. I've tried defining an enum in a #c ... #endc
section and using the straight enum
hook, but this gives precisely the same problem.
Should I give up using c2hs and use something else? Is there a sensible way around this problem rather than simply hard-coding constant values?