haskell / c2hs

c2hs is a pre-processor for Haskell FFI bindings to C libraries
http://hackage.haskell.org/package/c2hs
Other
199 stars 50 forks source link

Workaround for GenBind.evalCCast error #239

Open Krantz-XRF opened 5 years ago

Krantz-XRF commented 5 years ago

I get the following message when using enum define:

c2hs.exe: Feature not yet implemented:
  GenBind.evalCCast: Casts are implemented only for integral constants

The macros involved are #defineed in terms of other helper macros like:

#define WRAPPER(x)    ((int)((x) & 15) << 16)
#define MACRO_ORIGIN  42
#define MACRO_TEST    WRAPPER(MACRO_ORIGIN)

Then, when I refer to MACRO_TEST in my .chs file like this, c2hs will fail:

{#enum define Flags { MACRO_TEST as Test } deriving (Eq, Show) #}

The header file is a system header, so I cannot just modify the definition. Is there any workaround for this, or should I just rewrite enum define by hand?