I keep hearing that the C primitive types (with the exception of char) are ill-defined and the sizes are not guaranteed. Obviously if I am trying to pack a transmission containing exactly 32-bits, then using unsignedint is unacceptable.
In what conditions will the definition of an unsignedint change? Is this:
A) Compiler defined,
B) Build environment defined,
C) Build target defined, or
D) Runtime enviornment defined? <-- This one is scary!
Can someone give an example of where an unsignedint is not 32 bits?
Does the C standard really make a difference between any of A, B, C or D? In C99 and later you can use the fixed width integer types defined in stdint.h. uint32_t is a 32 bit unsigned integer.
Can someone give an example of where an unsigned int is not 32 bits?
Most of the 16-bit systems from the early 90s had 16-bit ints (16 bit is the minimum required by the C standard, incidentally).
Some early 64-bit systems (Cray is usually mentioned) had 64-bit ints.
Ah great! I've seen people use int32_t but I never knew where it was defined. I thought it was some compiler's version of VS's __int32.
Since it's defined in cstdint in my implementation as typedefint int32_t; and is gaurunteed to be 32 bits, then I can conclude that this is compiler specific. That's good news because I was worried that the effects of my program would change if I tried it on some other machine.