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

1 Answer

0 votes
#define STATIC_ASSERT _Static_assert

STATIC_ASSERT(sizeof(int) == 4, "Expecting int to be 32 bit (4 bytes)");

int main(void) {


}




/*
compile:

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

*/

 



answered Apr 27, 2022 by avibootz
...