[ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
#define
s for Boolean variables
or values. Declare them as an appropriate built-in type such as
int
.
upper - lower
is the number of
values inside the interval. This practice also simplifies iteration
over the interval with for
by reducing the amount of necessary
thought: `<' can be used instead of the less-common `<='.
x & 7u
, not x & 7
. Bitwise operations are less
well-defined on signed types.
typedef
typedef
. Code is clearer if the actual
type is visible at the point of declaration.
Do not declare a typedef
for a struct
, union
, or
enum
. Do not declare a typedef
for pointer types, because
they can be very confusing.
A function type is a good use for a typedef
because it can
clarify code. Give a function typedef
a lowercase name with the
ending _func
. The type should be a function type, not a
pointer-to-function type. That way, the typedef
name can be used
to declare function prototypes. (It cannot be used for function
definitions, because that is explicitly prohibited by the ANSI
standard.)
[ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |