5 ms·
>Need to know that int is 32 bit? Not a problem. I have 15 years of programming on 8but micros where that assumption/declaration is crazy. :) Never use int. A
by SlowRobotAhead 8y ago
>Need to know that int is 32 bit? Not a problem.
I have 15 years of programming on 8but micros where that assumption/declaration is crazy. :)
Never use int. Always uint32_t. There! Problem of portability solved.
- MaxBarraclough 8y ago> I have 15 years of programming on 8but micros where that assumption/declaration is crazy. :) Right, but that's the point here - we're discussing how to describe a stricter variant of C, which make exactly the kinds of guarantees that preclude exotic architecture targets. Ultra-portability isn't a goal for many codebases.
- SlowRobotAhead 8y agoThen... make uint32_t the standard and this is never a problem ever again?
- MaxBarraclough 8y agouint32_t is already available on the platforms where it makes sense to support the type. It is a strength of the C language that it also supports exotic platforms. By 'standard' do you just mean more widespread use? Some APIs already do something like this, such as Windows with its 'DWORD'.
- int_19h 8y agouint32_t is in the standard since C99. But it is conditionally present - it's only there if the platform can provide it. In practice, all platforms that most software cares about do so. But it's not actually codified everywhere, and that codification is what I was talking about.