3 ms·
> 2. Realize the program does not work because the types have different sizes now Such an enormous amount of time in C/C++ programming is devoted to accounting
by WalterBright 4y ago
> 2. Realize the program does not work because the types have different sizes now
Such an enormous amount of time in C/C++ programming is devoted to accounting for the size of an int, long, wchar_t, and long long being unreliable when porting.
This is why D has int fixed at 32 bits, long fixed at 64 bits. It's amazing how the problems just melt away.
Now, just remember to use size_t for everything used as an index, and you're good to go. (ptrdiff_t is almost never needed.)
- yardstick 4y agoIsn’t it similar in C with using uint16_t, uint32_t, etc? IMO it helps to write programs from the ground up that you know will need to be cross compiled.
- WalterBright 4y agoYes, you could use int32_t. But who wants to type that? People default to convenience, and that's int. Besides, the C Standard Library doesn't even use stdint.h. Now you've got unknown implicit integer conversions going on. It's just not a solution.