[C2hs] Re: C2hs and c 'struct' declarations
Thomas DuBuisson
thomas.dubuisson at gmail.com
Sun Sep 20 20:01:48 EDT 2009
I spoke too soon! The answer, as you probably already know, is a #c directive:
#c
typedef struct point point_t;
#endc
Thanks for the tool!
Thomas
On Sun, Sep 20, 2009 at 4:39 PM, Thomas DuBuisson
<thomas.dubuisson at gmail.com> wrote:
> Hello c2hs!
>
> I'm having an issue when using get and set hooks. Take the following
> example c code:
>
> typedef struct {
> int x;
> int y;
> } point;
>
> This has easy bindings:
>
> {#pointer *point as Point#}
>
> getX :: Point -> IO CInt
> getX = {#get point->x#}
>
> setX :: Point -> CInt -> IO ()
> setX p i = {#set point->x} p i
>
> But what if the header file doesn't typedef?
>
> struct point {
> int x;
> int y;
> };
>
> It seems c2hs can't bind to these data structures, the straight
> forward way of replacing 'point' with 'struct point' isn't parsed.
> Any combination of parens or quotes to make it parse as a single token
> haven't worked - also I see nothing in the tutorial. Any advice?
>
> Thomas
>
More information about the C2hs
mailing list