Discuss here different C compiler set ups, and compiling executables for the ESP8266

User avatar
By Ravi S Kashi
#41675 Hello Guys,

I am creating a message structure for serial communication with another MCU.

I want to create a structure with the fields packed so that I can use an union that will allow me both field access and stream access.

this can work only if I can pack the structure without padding bytes. How does one do this with CHERTS MinGW setup?

Code: Select alltypedef struct
{
   byte fld1;
   byte fld2;
} field_type;

typedef union
{
   field_type fld;
   byte             arr[2];
} packet_type;
User avatar
By dkinzer
#41726
Ravi S Kashi wrote:this can work only if I can pack the structure without padding bytes. How does one do this with CHERTS MinGW setup?


Code: Select all#pragma pack(push, 1)

typedef struct
{
   byte fld1;
   byte fld2;
} field_type;

typedef union
{
   field_type fld;
   byte             arr[2];
} packet_type;

#pragma pack(pop)