2 ms·
i16 seems to be a typedef for short int, which may be actually be larger than 2 bytes depending on the compiler.
by aleksei 9y ago
i16 seems to be a typedef for short int, which may be actually be larger than 2 bytes depending on the compiler.
- minipci1321 9y agoEven more so: -- the fact that the code didn't use the int16_t from stddef.h but rather defined their own, could hint in the sense that a signed-int-over-exactly-16-bits might be unavailable in the ABI. People defining their own exact-width integral types (instead of pulling in stddef.h), rarely think about how that makes the code harder to interpret for a reader. Now, if the type i16 might indeed be wider than 16 bits, sizeof becomes perfectly justified but '16' is not.
- ivanbakel 9y agoIf it's specified as i16, it would be exactly two bytes in all situations - there would be no logic in including a size parameter that didn't actually mean anything, and sized ints are specifically meant to be platform-independent.
- makapuf 9y agoBut then why not use stdint ?