22. Summary of Portability Recommendations
- Port. Rec. 1
- Avoid the direct
use of pre-defined data types in declarations.
- Port. Rec. 2
- Do not assume
that an
int
and a long
have the same size.
- Port. Rec. 3
- Do not assume
that an
int
is 32 bits long
(it may be only
16 bits long).
- Port. Rec. 4
- Do not assume
that a
char
is signed
or unsigned
.
- Port. Rec. 5
- Always set
char
to unsigned
if 8-bit ASCII is used.
- Port. Rec. 6
- Be careful not
to make type conversions from a `shorter' type to a `longer' one.
- Port. Rec. 7
- Do not assume
that pointers and integers have the same size.
- Port. Rec. 8
- Use explicit type
conversions for arithmetic using signed and unsigned values.
- Port. Rec. 9
- Do not assume
that you know how an instance of a data type is represented in memory.
- Port. Rec. 10
- Do not assume
that
long
s, float
s, double
s or
long double
s may begin at arbitrary addresses.
- Port. Rec. 11
- Do not depend
on underflow or overflow functioning in any special way.
- Port. Rec. 12
- Do not assume
that the operands in an expression are evaluated in a definite order.
- Port. Rec. 13
- Do not assume
that you know how the invocation mechanism for a function is implemented.
- Port. Rec. 14
- Do not assume
that an object is initialized in any special order in constructors.
- Port. Rec. 15
- Do not assume
that static objects are initialized in any special order.
- Port. Rec. 16
- Do not write
code which is dependent on the lifetime of a temporary object.
- Port. Rec. 17
- Avoid using
shift operations instead of arithmetic operations.
- Port. Rec. 18
- Avoid pointer
arithmetic.