3 ms·
> On the other hand, `sizeof (int8_t)` is the same size no matter which architecture you are running on. EDIT: See account42's reply below. ORIGINAL COMMENT:
by acuozzo 5y ago
> On the other hand, `sizeof (int8_t)` is the same size no matter which architecture you are running on.
EDIT: See account42's reply below.
ORIGINAL COMMENT: No, it's not. CHAR_BIT is not required to be 8 and sizeof (int8_t) is not required to be 1. Hell, int8_t is not even required to be present in <stdint.h>, but int_least8_t is.
- dzaima 5y agohuh, I guess that's still not hard-coded. But a non-8-bit-byte system probably runs near nothing to interface with anyway, and would definitely need a completely separate ABI in any scenario.
- account42 5y agoCHAR_BIT is required to be at least 8, int8_t is required to be exactly 8 bits if present, sizeof(int8_t) is required to return an integer size where sizeof(char) is 1. Hence, if int8_t is present then CHAR_BIT must be 8 and sizeof(int8_t) == 1.
- steveklabnik 5y agoTo add a teeny bit to this, POSIX specifies CHAR_BIT must be 8, but C defines it as >= 8.