How to align data to 1 byte ?

How set data alignment to 1 byte ?

I’ve got struct with bit fields:

struct frame_header
{
struct
{
unsigned short int type:15;
unsigned short int ack:1;
} frame_info;
unsigned short int len;
}

#include <_pack1.h> is one way.

Or use gcc attributes: gcc.gnu.org/onlinedocs/gcc/Varia … Attributes

thx, I’ve found 2 ways :slight_smile:

#include <_pack1.h>
struct init_s
{
char a;
short b;
};
#include <_packpop.h>

  • or -

struct init_s
{
char a;
short b;
} attribute((packed));