27 Jul 20:27
Suggestions for #defines with FFI
From: John Goerzen <jgoerzen <at> complete.org>
Subject: Suggestions for #defines with FFI
Newsgroups: gmane.comp.lang.haskell.cafe
Date: 2005-07-27 18:28:38 GMT
Subject: Suggestions for #defines with FFI
Newsgroups: gmane.comp.lang.haskell.cafe
Date: 2005-07-27 18:28:38 GMT
Hi, I'm writing a Haskell interface to a library that #defines about 100 constants corresponding to numeric exit codes. It also defines hundreds of contants, over the same numbering ranges, for other purposes. The exit codes are non-contiguous as well. So my question is: is there a nice way I can represent this in Haskell, preferably without having to key in all 100 constants? Or will I just have to list all the options and give up type checking to differentiate one purpose of a constant from another? Thanks, -- John
I'd rather be able to directly re-export all that again, saving me
having to key it all in manually. Or perhaps declare my own transformer
over it (a plugin of sorts, perhaps, so I could work nicely with
enums-from-macros in the scenario I've described)
> I mentioned this in the Tutorial: hsffig gives the Haskell compiler the
> same look at information about the library to import as the C compiler
> would have. It is hard to separate such things: your header file that
> you include may include ten other headers, five of them related to the
> library, and the rest from /usr/include
I think, though, that it shouldn't be too hard to filter the data coming
back from gcc. For instance, you could just look for stuff after a line
ilke:
# 1 "/usr/include/ldap.h"
and start ignoring when you see a reference to any other file.
> >3) It tried to list some of the GCC internal conditionals as constants,
RSS Feed