How to use _Static_assert to check if unsigned char is 1 byte in compile time in C

1 Answer

0 votes
typedef unsigned char u8;

#define STATIC_ASSERT _Static_assert

STATIC_ASSERT(sizeof(u8) == 1, "Expected u8 to be 1 byte");


int main(void) {


}




/*
compile:

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

*/

 



answered Apr 27, 2022 by avibootz
...