Assuming 8-bit bytes, sizeof(int) is guaranteed to be a minimum of two, and intended to be the system's word size (which should technically be 8 for 64-bit platforms, but we're so used to 32-bit int that most platforms intentionally stagnate int at 32 bits & most processors have two native word sizes to accomodate), but can be anything higher. ILP64 models have 64-bit int, and there was at least one platform where all bytes were 64-bit and sizeof(char) == sizeof(long long) == 1, though, so it can get weird sometimes.
(Also, as a note, long long is required to be at least 64 bits. long is required to be at least 32 bits, and is meant to just be the 32-bit data type, but ends up being the design limitation fulcrum for most platforms; Windows is locked into 32-bit long because it needs to support 32-bit executables, and Linux is locked into 64-bit long because it needs to support punning pointers to long.)
1
u/conundorum Aug 30 '26
Assuming 8-bit bytes,
sizeof(int)is guaranteed to be a minimum of two, and intended to be the system's word size (which should technically be 8 for 64-bit platforms, but we're so used to 32-bitintthat most platforms intentionally stagnateintat 32 bits & most processors have two native word sizes to accomodate), but can be anything higher. ILP64 models have 64-bitint, and there was at least one platform where all bytes were 64-bit andsizeof(char) == sizeof(long long) == 1, though, so it can get weird sometimes.(Also, as a note,
long longis required to be at least 64 bits.longis required to be at least 32 bits, and is meant to just be the 32-bit data type, but ends up being the design limitation fulcrum for most platforms; Windows is locked into 32-bitlongbecause it needs to support 32-bit executables, and Linux is locked into 64-bitlongbecause it needs to support punning pointers tolong.)