Complete the code to define a packed struct in C.
struct __attribute__(([1])) PackedData {
char a;
int b;
};The __attribute__((packed)) tells the compiler to pack the struct without padding bytes.
Complete the code to specify 1-byte alignment for the struct.
struct Data {
char a;
int b;
} __attribute__(([1](1)));The __attribute__((aligned(1))) forces the struct to have 1-byte alignment, minimizing padding.
Fix the error in the struct declaration to correctly pack the struct.
struct Data {
char a;
int b;
} __attribute__(([1]));The correct attribute to pack a struct is packed. Other options are invalid or incorrect.
Fill both blanks to create a struct with 2-byte alignment and packed attribute.
struct Data {
char a;
short b;
} __attribute__(([1])) __attribute__(([2](2)));Use packed to remove padding and aligned(2) to set 2-byte alignment.
Fill all three blanks to define a packed struct with 4-byte alignment and a member with 2-byte alignment.
struct Data {
char a;
short b __attribute__(([1](2)));
} __attribute__(([2])) __attribute__(([3](4)));The member b is aligned to 2 bytes, the struct is packed and aligned to 4 bytes.