A previous post of mine raised the topic of anonymous structs, with several commentators saying these were not allowed in C++.
Here is a construction that I use a lot: is this legal C++?
const int HeaderSize = 8192;
struct Header
{
union
{
struct
{
int r;
// other members
};
unsigned char unused[HeaderSize]; // makes Header struct's size remain constant as members are added to the inner struct
};
// Default constructor
Header()
{
}
};