3 ms·
I actually found it a welcome and refreshing change from the excessively verbose and spread-out style that seems to have become popular these days (of which Jav
by userbinator 9y ago
I actually found it a welcome and refreshing change from the excessively verbose and spread-out style that seems to have become popular these days (of which Java and C# are the main examples.)
I'm not sure all the casts are necessary, however, and I'd probably reduce usage of some sizeofs just using the constant (sizeof(i16) should obviously be 2, if the name is any indication.)
- kardos 9y ago> I'd probably reduce usage of some sizeofs just using the constant Why? The sizeof is resolved into a constant at compile time, ie, no runtime cost. I see the 'sizeof(i16)' as conveying more information than a '2'.
- aleksei 9y agoi16 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 ?