Datasheet
/* A simple macro which returns greater of its 2 arguments: */
#define _MAX(A, B) ((A) > (B)) ? (A) : (B)
/* Let's call it: */
x = _MAX(a + b, c + d);
/* Preprocessor will transform the previous line into:
x = ((a + b) > (c + d)) ? (a + b) : (c + d) */
It is highly recommended to put parentheses around each argument in the macro
body in order to avoid possible problems with operator precedence.
Undefining Macros
The #undef directive is used to undefine a macro.
#undef macro_identifier
The directive #undef detaches any previous token sequence from macro_identi-
fier
; the macro definition has been forgotten, and macro_identifier is undefined.
No macro expansion occurs within the #undef lines.
The state of being defined or undefined is an important property of an identifier,
regardless of the actual definition. The
#ifdef and #ifndef conditional directives,
used to test whether any identifier is currently defined or not, offer a flexible mech-
anism for controlling many aspects of a compilation.
After a macro identifier has been undefined, it can be redefined with #define, using
the same or different token sequence.
222
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Language Reference
mikroC PRO for AVR
CHAPTER 5