Question.1
A developer validates a communication packet struct:
struct __attribute__((packed)) Packet { uint8_t id; uint32_t payload; }; static_assert(sizeof(Packet) == 5, "Packet must be 5 bytes");
What does this achieve?
Select Answer
Checks the struct size at runtime and crashes if wrong
Checks at compile time -- if sizeof(Packet) is not 5, the build fails with the error message, preventing corrupted protocol frames
Checks only in debug builds
No effect -- static_assert is just documentation