|
|
|
|
|
by rkangel
1020 days ago
|
|
The simple version is that there are two use cases - the world where you want the size of types to match the target (e.g. int) and the world where sizes are defined by the coder (uint32_t). You want to handle both of those. That's a nice theory and is what we've got, but it falls down in a few places. The first is that the "int" world has got a bit munged - some platforms make some slightly strange choices for long and short and so you can't always rely on it (although int is usually pretty sensible). The other is that when doing unsigned maths, rollover is silent so generally you really need to know the exact size at coding time so that you can ensure that rollover doesn't happen silently. Together, these mean that you're generally just better using uint32_t (etc.) all over the place and you get more predictable results. |
|