Kanbaru 🌟 (one hikari of too many)

on 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!

1 replies →
1 replies

Colin Burgess

(replying to Kanbaru 🌟 (one hikari of too many))

@hikari it plays merry havoc if you have printf warnings enabled. Bad enough to make you use the PRIx64 macros from inttypes.h? Never!

Kanbaru 🌟 (one hikari of too many)

(replying to Colin Burgess)

@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.

Kanbaru 🌟 (one hikari of too many)

(replying to Kanbaru 🌟 (one hikari of too many))

long long was a mistake

1 replies →
1 replies

Ridley @ WATCH LYCORECO

(replying to Kanbaru 🌟 (one hikari of too many))

@hikari long was a mistake, which later necessitated the creation of long long

Kanbaru 🌟 (one hikari of too many)

(replying to Ridley @ WATCH LYCORECO)

@rcombs well, short was definitely also a mistake, then

Ridley @ WATCH LYCORECO

(replying to Kanbaru 🌟 (one hikari of too many))

@hikari nah short is sane, it's 16-bit on all common desktop/server/etc platforms

Kanbaru 🌟 (one hikari of too many)

(replying to Ridley @ WATCH LYCORECO)

@rcombs but int being short or long depending on the platform makes me sad and has broken so much

Ridley @ WATCH LYCORECO

(replying to Kanbaru 🌟 (one hikari of too many))

@hikari where is int = short, outside embedded? (like, for the most part these days it's neither on 64-bit even?)

Kanbaru 🌟 (one hikari of too many)

(replying to Ridley @ WATCH LYCORECO)

@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

Kanbaru 🌟 (one hikari of too many)

(replying to Kanbaru 🌟 (one hikari of too many))

…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…

Kanbaru 🌟 (one hikari of too many)

(replying to Kanbaru 🌟 (one hikari of too many))

ok are you ready for this? my hottest c take

int should be 64-bit on 64-bit platforms

Saagar Jha

(replying to Kanbaru 🌟 (one hikari of too many))
@hikari If you use Swift you can enjoy its ILP64 goodness

Kanbaru 🌟 (one hikari of too many)

(replying to Saagar Jha)

@saagar this is because of NSInteger isn't it? Objective-C is the only good C

Saagar Jha

(replying to Kanbaru 🌟 (one hikari of too many))
@hikari Maybe, but also that ILP64 is typically advantageous for compiler optimizations