What\'s the best way to declare an integer type which is always 4 byte on any platforms? I don\'t worry about certain device or old machines which has 16-bit int
You need to include inttypes.h
instead of stdint.h
because stdint.h
is not available on some platforms such as Solaris, and inttypes.h
will include stdint.h
for you on systems such as Linux.
If you include inttypes.h
then your code is more portable between Linux and Solaris.
This link explains what I'm saying: HP link about inttypes.h
And this link has a table showing why you don't want to use long
or int
if you have an intention of a certain number of bits being present in your data type.
IBM link about portable data types