How to use _Static_assert to check if short is 2 byte in compile time in C

1 Answer

0 votes
#define STATIC_ASSERT _Static_assert

STATIC_ASSERT(sizeof(short) == 2, "Expecting short to be 2 bytes");

int main(void) {


}




/*
compile:

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

*/

 



answered Apr 28, 2022 by avibootz
...