3 ms·
That's right. The crazy one is `long`, which is 32 bits on some platforms and 64 bits on other platforms. I solved that problem by never using `long`, opting
by WalterBright 3y ago
That's right.
The crazy one is `long`, which is 32 bits on some platforms and 64 bits on other platforms.
I solved that problem by never using `long`, opting instead for `int` for 32 bits, and `long long` for 64. `long` should be deprecated for 32 and 64 bit platforms, it's not fixable.
- WalterBright 3y agoIn D, we use `int` for 32 bits, `long` for 64 bits, and `size_t` for a pointer index. All the craziness just melts away. You can port the code back and forth between 32 and 64 bit patterns, and it just works. All those `int32_t` types are out back in the bin along with the whiteout.
- volemo 3y agoI like Rust’s choice for basic types: initial and the number of bits: u8, i32, f64, etc. (I’m not comparing the languages in any way here, just praising a clean notation.)
- WalterBright 3y agoI suspect the impetus for suffixing the number of bits is a bit of a backlash from C, where you never know how many bits are in a type. That has caused C programmers a lot of trouble and extra work.
- NikkiA 3y agoint32_t and int64_t are plenty unambiguous, it's been 25 years.