wc-duck / datalibrary

Open Source Data Library for data serialization.
Other
42 stars 8 forks source link

Usage of union in type is valid in dl, but not in generated header #52

Open joeldevahl opened 8 years ago

joeldevahl commented 8 years ago

Using a union in a type is valid in DL but generates a header where the union type is declared after the struct that uses it.

I can work around this by using a pointer to the union in the type but preferably I would like it built in. One solution would be to sort the types and unions on dependencies (types and union only depending on PODs first etc.)

wc-duck commented 8 years ago

This is a known issues ( known by me ) and you can work around it in the same way as I have done in the unittests, by adding multiple "types" sections in the tld and manually order your types.

"types" : { "type_a" : {} }, "unions" : { "union_a" : { "members" : [ "type" : "type_a" ] } }, "types" : { "type_b" : { "members" : [ "type" : "union_a" ] } }

not perfect, but it works.

joeldevahl commented 8 years ago

Ah, great! That is fine by me, though it would be nice if DL warned about it when compiling. Also nice since it doesn't change order of types between tld and header