haskell / c2hs

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

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

Open hesselink opened 8 years ago

hesselink commented 8 years ago

I'm getting the message

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

when compiling kqueue, using c2hs version 0.25.2. I've tested GHCs 7.4, 7.6 and 7.8, and I'm pretty sure it worked on at least some of those in the past. Any idea what this could be? Something that changed in c2hs, or something in my OS (I'm on Mac OS X 10.10.5)?

ian-ross commented 8 years ago

Urgh. No idea, I'm afraid. I don't have a Mac to test C2HS on, so OS X behaviour is a bit hit and miss. The only way I've ever been able to test things on OS X is using a kind of horrible Travis setup, but the turnaround times on that obviously make it completely impractical. I do a fair bit of testing for Linux (running regression tests against a number of packages that use C2HS), but I have no way of doing that for OS X. If someone was to provide me a login to an OS X box somewhere, I'd be happy to look at this (and even set up regression tests on OS X), but unless that happens, I can't really do much about it.

hesselink commented 8 years ago

We have an old laptop at work, I can try to get it set up tomorrow. I gave it a try today but it didn't finish booting, so don't get your hopes up... :/

Is there some way I can help debug this on my machine?

ian-ross commented 8 years ago

My previous efforts at debugging OS X problems have mostly consisted of browsing through various versions of the OS X C header files I found online and using the Travis setup I mentioned. That was no fun, and I don't want to try it again!

However, you could email me the transitive closure of the C #include dependencies of your package, so I can have a look through them for what might be causing the problem. And you could also run C2HS on the offending file with all its debug switches on and send me the output:

c2hs -d trace -d ctrav -d genbind KQueue.chs

That doesn't always help that much, but it would be a start.

hesselink commented 8 years ago

Thanks, I've sent the output and the headers.

ian-ross commented 8 years ago

Minimal test case:

Tst.chs:

module Tst where

#include "tst.h"

{# enum Chk {underscoreToCase} #}

tst.h:

enum { a  = 1 };

enum Chk { b = ((unsigned int)a) };

Seems to be to do with casting C enumeration values.