Am 04.02.15 um 22:31 schrieb Christopher Pisz:
If you want to use a unsigned int then use an unsigned int. There is no
purpose at all to use a typedefed renaming when you intend on it being
an specific type anyway. If you want to know the size, then use sizeof.
Fixed-width integers are very useful types in many fields of computing.
In fact, I claim that they are more useful then the "polymorphic" int,
long, short nonsense. For example, to implement the Mersenne twister you
need to use unsigned 64 bit arithmetics. Or to read image files from
disk into memory, you need unsigned 8 bit or unsigned 16 bit integer
types. Extremely easy if you have either cstdint or inttypes, but
extremely annoying when you need to remember that long on Windows is
always 32bit regardless of pointer size, whereas it is 64 bit on a 64bit
Linux and 32 bit on a 32bit Linux etc. The names of these typedefs are
also widespread and there is cstdint, added in C++11 for that. I can't
understand why you think these are not useful, and I don't see why you
think it is a C problem rather than a C++ one.
OTOH, using the generic "int" makes the program behave differently on
different platforms. For example a program computing the factorial using
integer arithmetics overflows for different input at different
platforms, if just int or unsigned is used.