Keil Logo

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.

  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.