That means int16_t
is defined as short
on your machine, not all machines.
Just use the int16_t
where you absolutely need a 16bit integer type; it will be defined as appropriate on all platforms that provide stdint.h
(which should be all that support C99, or cstdint
for C++).
[Edit] To clarify, the "stdint.h
" header file is provided by the C (or C++) compiler, so its contents will likely vary per compiler, version, system, CPU architecture, etc. That is, the authors of the compiler suite know exactly what types have what sizes on which systems. Looking at that file on just one system only tells you about the definitions for a particular version of a particular compiler on a particular OS on a particular architecture (e.g. GCC 4.2 on Darwin x86_64, or Visual Studio on WinNT Alpha, or ICC on Solaris IA32, etc). Some systems, especially embedded ones, might have different type sizes, so a short
might not always be 16 bits, and the compiler would know the right size to use for that bit length.
If you look at the file stdint.h
on another system the definitions might be different, or they might be the same - but its purpose is to provide the definitions for integer types of guaranteed bit lengths.
int16_t
is probably guaranteed to be 16 bits. – Keratoidtypedef
rather thanshort
. – Whigstdint.h
might containtypedef int int16_t;
But, it does not have to be defined if it can't be done correctly. There are another set of related types which escape at this moment. Anyway the compiler will throw an error if it isn't there, so it should be testable. – Misdoubt