The Arm "#pragma anon_unions" allows:
typedef struct {
uint32_t sensorID;
uint8_t messageHeader;
uint8_t messageID;
uint16_t payloadLength;
} Header;
typedef struct {
uint8_t startOfPacket[SERIAL_SOP_SIZE];
Header; // Anonymous.
uint8_t payload[SIZE];
} Packet;
Packet packet;
packet.messageID = 1; // Referencing member of Header through a Packet.
Any ideas on getting this code to compile in VisualStudio?
It compiles in Visual C++ but only in C mode:
A Microsoft C extension allows you to declare a structure variable within another structure without giving it a name. These nested structures are called anonymous structures. C++ does not allow anonymous structures.