wc-duck / datalibrary

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

Created a failing test for two types which refer to each other #143

Closed Tisten closed 1 year ago

Tisten commented 1 year ago

TL;DR: and made a fix for the failure

More details: The old code had inline definitions of operator[], begin() and end() for C++, but if a type which wasn't declared yet were used then it caused a compile error:

error C2143: syntax error: missing ';' before '*'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2238: unexpected token(s) preceding ';'

and even with a forward declare it caused an error:

error C2036: 'MyTypeName *': unknown size

The C code were fine, but the generated header weren't very readable.

I introduced a macro for the array, and a templated implementation of the C++ case which solves the issue.