[Haskell-cafe] c2hs seems to ignore the types I give it when generating foreign import declarations

Manuel M T Chakravarty chak at cse.unsw.edu.au
Sun Dec 18 20:19:18 EST 2005


Benjamin Franksen:
> On Monday 12 December 2005 02:17, Manuel M T Chakravarty wrote:
> > The darcs version of c2hs
> >
> >   darcs get --partial http://www.cse.unsw.edu.au/~chak/repos/c2hs/
> >
> > now permits the use of a `nocode' keyword ...
> 
> Hello
> 
> not directly related, but are there any plans to add the (still?) 
> missing 'enum define' hooks in teh near future?

This feature is still on the todo list, but it's hard to say when I'll
get around to implementing it.  One reason why enum define is not so
high on the top of the list is that there is a simple workaround.  Here
is an example:

-=- myheader.h -=-
/* A #define enum
 */
#define THIS 1
#define THAT 2

-=- MyBinding.chs -=-
import C2HS

#c
enum ThisThat {
  This = THIS,
  That = THAT
};
#endc
{#enum ThisThat {}#}

In other words, you can use inline C in .chs files to define a C enum
that an enum hook can process.  This is not that much more verbose as
what you would have to write in an enum define hook anyway (as you need
to enumerate all macro names that contribute to the enum anyway).

Moreover, I am always grateful for patches that improve c2hs.

Cheers,
Manuel




More information about the Haskell-Cafe mailing list