comp.lang.c FAQ list
Since C doesn't define sizes exactly,
I've been using
like int16 and
I can then define these typedefs
to be int, short, long,
etc. depending on what machine I'm using.
That should solve everything, right?
If you truly need
over exact type sizes,
this is the right approach.
There remain several things to be aware of:
- There might not be an exact match on some machines.
(There are, for example, 36-bit machines.)
- A typedef like int16 or int32
if its intended meaning is ``at least'' the specified size,
because types int and long
are already essentially defined as being
``at least 16 bits'' and
``at least 32 bits,'' respectively.
do anything about byte order problems
if you're trying to interchange data
or conform to
externally-imposed storage layouts).
- You no longer have to define your own typedefs,
because the Standard header <inttypes.h>
contains a complete set.
See also questions
about this FAQ list