comp.lang.c FAQ list
·
Question 1.3
Q:
Since C doesn't define sizes exactly,
I've been using
typedefs
like int16 and
int32.
I can then define these typedefs
to be int, short, long,
etc. depending on what machine I'm using.
That should solve everything, right?
A:
If you truly need
control
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
accomplishes nothing
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.
- Typedefs
will never
do anything about byte order problems
(e.g.
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
10.16
and
20.5.
about this FAQ list
about eskimo
search
feedback
copyright
Hosted by