4 ms·
> The cases where you want platform-specific integer width (that is not something like size_t/uintptr_t) is extremely niche (...) I think you got it backwards.
by chipdart 2y ago
> The cases where you want platform-specific integer width (that is not something like size_t/uintptr_t) is extremely niche (...)
I think you got it backwards. There are platform-specific ints because different processors have different word sizes. Programing languages then adjust their definitions for these word sizes because they are handled naturally by specific processors.
So differences in word sizes exist between processors. Either programming languages support them, or they don't. Also, there is also specific needs to handle specific int sizes regardless of cpu architecture. Either programming languages support them, or don't.
And you end with "platform-specific integer widths" because programming languages do the right thing and support them.
- zokier 2y agoThe fact that we have all these different 64 bit data models demonstrates clearly how the connection between word size and C types is completely arbitrary and largely meaningless. And this is not specific to 64 bit either, same sort of thing happens on 8 bit platforms too. So you can not rely on `int` (or any other type) being word sized. Furthermore I argue that word size is not really something that makes sense to even expose at language level, the whole concept of word size is somewhat questionable. CPUs operate on all sort of things that can have different sizes, trying to reduce that to single "word size" is futile.