Re: [Vala] Mapping unnamed nested structs from C lib to Vala



On Sat, Jul 14, 2012 at 12:12 AM, foracc <foracc d00m info> wrote:

Hey there,

I got an unnamed struct nested in another struct in a C library. Like this:

        typedef struct {
                int a;

                struct {
                        int x;
                        int y;
                } vals;
        } mystruct;

How would I map that to Vala? I tried this:

        [Compact]
        [CCode (cheader_filename="mylib.h", cname="mystruct")]
        public struct mystruct {
                public int a;

                [CCode (cname="vals.x")]
                int x;
                [CCode (cname="vals.y")]
                int y;
        }

It works, but isn't faithful to the original C library, and will run into
problems if the outer struct has equally named fields as the nested struct.


Call them vals_x, vals_y.

-- 
www.debian.org - The Universal Operating System


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]