GNOME Bugzilla – Bug 722754
Bad C code generated from struct array member initialization
Last modified: 2017-03-09 21:39:29 UTC
struct Foo { string[] bar; } public int main(string[] args) { Foo foo = {{"foo", "bar"}}; stdout.printf(foo.bar[0]); return 0; } $ valac-0.24 test.vala test.vala.c: In function ‘_vala_main’: test.vala.c:107:15: error: expected expression before ‘{’ token error: cc exited with status 256 Compilation failed: 1 error(s), 0 warning(s) $ valac-0.24 --version Vala 0.23.1
Genie code where this bug was found; profiles = new array of hid_profile[1] profiles[0] = { "stick", // name {"X", "Y"}, // axis null, // buttons false, // pointer false, // text input 0} // touch Work-around; profiles = new array of hid_profile[1] profiles[0] = { "stick", // name new array of string[2], // axis null, // buttons false, // pointer false, // text input 0} // touch profiles[0].axis[0] = "X" profiles[0].axis[1] = "Y" Where hid_profile is defined as; struct hid_profile name : string // profile name axis : array of string // how many buttons and their labels buttons : array of string // how many axis and their labels pointer : bool // pointer position needed text : bool // text input needed touch : int8 // touch input needed
*** This bug has been marked as a duplicate of bug 597817 ***