Interfacing with structs and anonymous unions with c2hs

Solution 1:

How about this: change the code so that you name the members. The layout in memory is the same so that it will be binary compatible. You would have to do this patch for each version of the lib.

struct monome_event {
    monome_t *monome;
    monome_event_type_t event_type;

    /* __extension__ for anonymous unions in gcc */
    __extension__ union {
        struct me_grid {
            unsigned int x;
            unsigned int y;
        } grid;

        struct me_encoder {
            unsigned int number;
            int delta;
        } encoder;

        struct me_tilt {
            unsigned int sensor;
            int x;
            int y;
            int z;
        } tilt;
    };
};