How to use _Static_assert to check if unsigned int is 4 byte in compile time in C

1 Answer

0 votes
typedef unsigned int u32;

#define STATIC_ASSERT _Static_assert

STATIC_ASSERT(sizeof(u32) == 4, "Expected u32 to be 4 bytes");

int main(void) {


}




/*
compile:

0 error(s), 0 warning(s) (0 minute(s), 0 second(s))

*/

 



answered Apr 27, 2022 by avibootz
...