Is this how one can use the the \"extra\" memory allocated while using the C struct hack?
Questions:
I have a C struct hack implementation below. My questio
It is 'correct', but you'd need a good reason to do that over a more reasonable solution. More commonly perhaps you'd use this technique to "overlay" some existing array to impose some sort of header structure on to it.
Note that GCC by extension allows a zero length array member for exactly this purpose, while ISO C99 "legitimises" the practice by allowing a member with empty brackets (only as the last member).
Note that there are some semantic issues - sizeof the struct will not of course account for the "flexible" size of the final member, and passing the struct "by value" will only pass the header and first element (or no element using the GCC extension or C99 flexible array member). Similarly direct struct assignment will not copy all the data.