C166 User's Guide

Undefining and Redefining

Macros are defined using the #define directive. Undefining or canceling a defined macro is done using the #undef directive. For example:

#define VALUE 123
int v1 = VALUE;
#undef VALUE
int v2 = VALUE;

expands into


int v1 = 123;

int v2 = VALUE;

Redefining a macro is simply using the #define directive to provide a new macro body for an existing macro definition. If the redefinition is identical to the original definition, the compiler goes on without emitting any type of diagnostic message. If, however, the redefinition is different, the compiler generates a warning since this may not be desired. To avoid the warning and redefine the macro, undefine the macro (using #undef) first.