17 Oct
2002
17 Oct
'02
4:18 p.m.
Antony Courtney <antony@apocalypse.org> wrote,
A relatively mundane question:
Is there a preferred means of writing a foreign import declaration for a C function with a prototype that takes an "enum" argument?
i.e., in C we have:
enum bar { GOOD, BAD };
void foo(enum bar x);
That's exactly the kind of scenario for which I have written C->Haskell: http://www.cse.unsw.edu.au/~chak/haskell/c2hs Using C->Haskell, you write into the binding module {#enum bar as Bar#} run it through the tool and get a Haskell data definition for `Bar', so that you can safely marshal between C's bar and Haskell's Bar. (See also the corresponding section in the manual <http://www.cse.unsw.edu.au/~chak/haskell/c2hs/docu/c2hs-3.html#ss3.5>.) Manuel