[prev in list] [next in list] [prev in thread] [next in thread] 

List:       haskell-c2hs
Subject:    [C2hs] C2hs and c 'struct' declarations
From:       Thomas DuBuisson <thomas.dubuisson () gmail ! com>
Date:       2009-09-20 23:39:21
Message-ID: 4c44d90b0909201639j23398fa9wb6b4a6822de7e3e () mail ! gmail ! com
[Download RAW message or body]

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
_______________________________________________
C2hs mailing list
C2hs@haskell.org
http://www.haskell.org/mailman/listinfo/c2hs
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic