struct inheritance between multiple files does not compile in C.
Submitted by Lim Jongrok
Link to original bug (#734295)
Description
When a struct inherits from other struct in other file, it does compile at vala level (generation of C Code), but it does not compile at C level with a "Unknown Type" error.
This can be reproduced with any struct inheritance, which one of more of struct definitions are separated in other file(s), and here is one of example. which has two struct in each file.
astruct.vala: (also attached)
public struct AStruct { public int a_field; }
bstruct.vala: (also attached)
public struct BStruct: AStruct { }
bar.vala: (also attached)
public static int main (string[] args) { BStruct bstruct = new BStruct (); return 0; }
[wsid@WSIDPC ~]$ valac --version Vala 0.25.1
[wsid@WSIDPC ~]$ valac astruct.vala bstruct.vala bar.vala
bar.vala:2.20-2.33: warning: deprecated syntax, don't use new' to initialize structs BStruct bstruct = new BStruct (); ^^^^^^^^^^^^^^ bar.vala:2.10-2.33: warning: local variable
bstruct' declared but never used
BStruct bstruct = new BStruct ();
^^^^^^^^^^^^^^^^^^^^^^^^
/home/wsid/bstruct.vala.c:11:9: error: unknown type name ‘AStruct’
typedef AStruct BStruct;
^
/home/wsid/bar.vala.c:12:9: error: unknown type name ‘AStruct’
typedef AStruct BStruct;
^
error: cc exited with status 256
Compilation failed: 1 error(s), 2 warning(s)
[wsid@WSIDPC ~]$ valac astruct.vala bstruct.vala bar.vala -C
bar.vala:2.20-2.33: warning: deprecated syntax, don't use new' to initialize structs BStruct bstruct = new BStruct (); ^^^^^^^^^^^^^^ bar.vala:2.10-2.33: warning: local variable
bstruct' declared but never used
BStruct bstruct = new BStruct ();
^^^^^^^^^^^^^^^^^^^^^^^^
Compilation succeeded - 2 warning(s)
The generated C files are attached, and bstruct.c and bar.c lacks of definition of AStruct.