#ifndef STRUCTS_H #define STRUCTS_H // Structs // ======= // For structs, a combination is needed to define the type of struct // IS = Struct (Empty or incomplete, neither primitive nor complex) // PS = Primitive struct (struct containing only primitive types) // CS = Complex struct (struct containing other structs and primitive) // NPS = Nested primitive struct // Covered combinations // ==================== // _IS = incomplete struct without a typedef (forward decl) // IS = incomplete struct // AIS = alias of an incomplete struct // (aliased) struct [ primitive | complex ] // ---------------------------------------- // _PS = primitive struct without a an alias // PS = primitive struct // _PSIa = primitive struct without an alias containing an incomplete array // PSIa = primitive struct containing an incomplete array // APSIa = alias of a primitive struct containing an incomplete array // _PSa = primitive struct without an alias containing an array // PSa = primitive struct containing an array // APSa = alias of a primitive struct containing an array // APS = Alias of primitive struct // _CS = complex struct without a an alias // CS = complex struct // ACS = alias of a complex struct // _CCS = complex complex struct without an alias // CCS = complex complex struct // ACCS = alias of a complex complex struct // // Nested structs // -------------- // there is always a hosting struct and a nesting struct // in case of double nesting it can be both // // simply nested struct [ primitive | complex ] // -------------------------------------------- // (aliased) hosting struct (complex always) // _HS = hosting struct without an alias // HS = hosting struct // AHS = alias of a hosting struct // _NPS = nested primitive struct without an alias // _NCS = nested complex struct without an alias // // doubly nested struct (complex always) // ------------------------------------- // _HHS = hosting hosting struct without an alias // HHS = hosting hosting struct // AHHS = alias of a hosting hosting struct // _NHS = nested hosting struct // _NNPS = nested nested struct // _NNCS = nested nested complex struct // // enums in structs // _NEHS = nested enum in hosting struct // _NENHS = nested enum in nested hosting struct // // // Arrays // ------ // Caution: The array combinations are covered in a not entirely systematic way. // There are designated primitive structs that contain complete/incomplete array // BUT, the use of array fields has been scattered a bit randomly in an attempt to cover all // combinations of struct fields: // * ia_P // * a_P // * a_PSa // * aAPSa // * iaACS // * aACS // // So, a few of the possible field types are missing. // Additionally, it gets a little blury with the complex structs (CS) because they dont further // specify exactly the types of their fields // _IS = incomplete struct without a typedef (forward decl) struct _IS; // IS = incomplete struct // AIS = alias of an incomplete struct typedef struct IS AIS; // // (aliased) struct [ primitive | complex ] // ---------------------------------------- // _PS = primitive struct without a an alias struct _PS { int x, y; }; // PS = primitive struct // APS = Alias of primitive struct typedef struct PS { int field__P_x; int field__P_y; } APS; // _PSIa = primitive struct containing an incomplete array without an alias struct _PSIa { int field__P; char field__Pa[]; }; // PSIa = primitive struct containing an incomplete array // APSIa = alias of a primitive struct containing an incomplete array typedef struct PSIa { int field__P; char field__Pa[]; } APSIa; // _PSa = primitive struct containing an array without an alias struct _PSa { int field__P; char field__Pa[3]; }; // PSa = primitive struct containing an array // APSa = alias of a primitive struct containing an array typedef struct PSa { int field__P; char field__Pa[3]; } APSa; // _CS = complex struct without a an alias struct _CS { struct _PS field__PS; APS field_APS; struct _PSa fiedld__PSa[3]; APSa field_APSa[3]; }; // CS = complex struct // ACS = alias of a complex struct typedef struct CS { struct _PS field__PS; APS field_APS; struct _PSa fiedld__PSa[3]; APSa field_APSa[3]; } ACS; // _CCS = complex complex struct without an alias struct _CCS { struct _CS field__CS; ACS x[]; }; // CCS = complex complex struct // ACCS = alias of a complex complex struct typedef struct CCS { struct _CS field__CS; ACS x[3]; } ACCS; // Nested structs // -------------- // there is always a hosting struct and a nesting struct // in case of double nesting it can be both // // simply nested struct [ primitive | complex ] // -------------------------------------------- // _HS = hosting struct without an alias // _NCS = nested complex struct without an alias struct _HS { int x, y; struct _NCS { ACS x; } _ncs; }; // (aliased) hosting struct (complex always) // HS = hosting struct // AHS = alias of a hosting struct // _NPS = nested primitive struct (never has alias) typedef struct HS { struct _NPS { int x, y; } _nps; int x, y; } AHS; // doubly nested struct (complex always) // ------------------------------------- // (And enums in struct) // // _HHS = hosting hosting struct without an alias // _NHS = nested hosting struct // _NNPS = nested nested primitve struct struct _HHS { int x, y; struct _NHS { int x, y; struct _NNPS { int x,y; } _nnps; } _nhs; }; // HHS = hosting hosting struct // AHHS = alias of a hosting hosting struct // _NNCS = nested nested complex struct // _NENHS = nested enum in nested hosting struct typedef struct HHS { int x, y; struct _NHS1 { int x, y; struct _NNCS { struct _CS a; } _nncs; enum _NENHS { _NENHS1, _NENHS2, _NENHS3 } _nenhs; } _nhs1; } AHHS; // _NEHS = nested enum in hosting struct struct _HS1 { int x, y; enum _NEHS { _NEHS1, _NEHS2, _NEHS3 } _nehs; }; #endif //STRUCTS_H