Re: [Vala] Incorrect C generated with union containing anonymous struct



On Thu, Oct 13, 2011 at 12:10 AM, Jan-Jaap van der Geer
<jjvdgeer inbox com>wrote:

(Excuses if this appears twice, but after waiting half an hour my
first attempt still hasn't appeared...)

I have the following struct:

typedef union foobar foobar;

union foobar
  {  struct
     {  char *bar;
     }
     foo;
  };

This fails since foo, the variable of _tmp1_ is undefined in C. I
could of course remove the [CCode (cname = "foo")] in the vapi but
that only changes the name to something else that is not known.

Is this a bug? Is there a workaround? Note that the C-code is
beyond my control, so workarounds involving changing the definition
of the struct in C will most probably not work...


That vapi is not supposed to be correct, it's only a case that has been
working until now. Wrap it like this:

struct foobar {
   [CCode (cname = "foo.bar")]
   public string bar;
}

Should write a FAQ for this.

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


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