Thread with 22 posts
jump to expanded poston x64 Linux, uint64_t is an alias of unsigned long, but on x64 macOS, uint64_t is an alias of unsigned long long. this doesn’t matter for C code, but it interacts badly with C++ overload resolution, even though sizeof(long) == sizeof(long long) on both systems. fun!
long long was a mistake
…I said “this doesn’t matter for C code”, but the way I tested this was with the _Generic macro (https://godbolt.org/z/v3c4n56jj), which is a C feature. also, you might be using really anal compiler flags…
ok are you ready for this? my hottest c take
int should be 64-bit on 64-bit platforms
@hikari ...but then what would the 32-but integer type be?
@saagar this is because of NSInteger isn't it? Objective-C is the only good C
@hikari Windows would like a word :)
@hikari I'm just surprised uint8_t isn't a unsigned short short
@hikari I believe they inherited that from freebsd
@hikari long was a mistake, which later necessitated the creation of long long
@rcombs well, short was definitely also a mistake, then
@hikari nah short is sane, it's 16-bit on all common desktop/server/etc platforms
@rcombs but int being short or long depending on the platform makes me sad and has broken so much
@hikari where is int = short, outside embedded? (like, for the most part these days it's neither on 64-bit even?)
@rcombs I mean yes we live in the 32-bit era now so desktops, laptops, phones and servers’ CPUs have sizeof(int) == 4, but embedded is a thing, and legacy OSes were a thing, and if you try to port legacy code to a modern OS you’ll suffer :p
@hikari oh if you find yourself porting pre-32-bit code to post-32-bit platforms then you have my sincerest condolences
@hikari oh deer
@hikari it plays merry havoc if you have printf warnings enabled. Bad enough to make you use the PRIx64 macros from inttypes.h? Never!
@colinburgess I wonder if those macros would even work here anyway. They’re probably using the at-least rather than exact-size typedefs and I don’t know if those are consistent. It’s such a mess.