C2hs: Binding Constants

I am trying to write a quick binding to some ioctl functions (in particular, get and set the window size) using c2hs. Here is 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 is available https://gist.github.com/nc6/8977936 )

When I try to compile this, I get:

c2hs: function not yet implemented: GenBind.evalConstCExpr: Casts not yet implemented.

I assume the cause of this problem is that C constants are defined using helper functions ( _IOWand _IOR) that the Haskell preprocessor cannot handle. However, it is not clear how best to fix this. I tried to define the enum in the section #c ... #endcand use a direct enumhook, but this gives exactly the same problem.

c2hs - ? , ?

+3
1

{#enum ... #} c2hs enum, enum C/++. #defines, c2hs .

, hsc2hs bindings-dsl, 2011 FFI.

+1

All Articles