How to access defines and enums in a convenient way?

Simon Marlow simonmar at microsoft.com
Fri Jun 6 05:42:39 EDT 2003


 
> I am doing some wrappers for c functions, and I need to 
> access defines, enums, and structs.
> 
> I am doing this by writing access functions in c, so that I can call
> them from Haskell.
> 
> Is there a way to write this c code inline in the Haskell 
> module?

You want to use a tool to make all this easier.  There are various tools available: green-card, c2hs, and hsc2hs are the most commonly-used ones these days.  Alastair Reid wrote a good comparison of the various tools (can't remember the link off hand though).

There are examples of hsc2hs code in the libraries - particularly fptools/libraries/unix has examples of doing defines, enums and structs.  Examples of green-card stuff can be found in fptools/libraries/HGL and fptools/libraries/X11.  Take a look at Manuel's GtkHS for c2hs examples.

Cheers,
	Simon




More information about the FFI mailing list