MQL5 Programming for TradersProgramming fundamentalsPreprocessorCancelling macro substitution (#undef)
- Including source files (#include)
- Overview of macro substitution directives
- Simple form of #define
- Form of #define as a pseudo-function
- Special operators '#' and '##' inside #define definitions
- Cancelling macro substitution (#undef)
- Predefined preprocessor constants
- Conditional compilation (#ifdef/#ifndef/#else/#endif)
- General program properties (#property)
Cancelling macro substitution (#undef)
Substitutions registered with #define can be undone if they are no longer needed after a particular piece of code. For these purposes, the #undef directive is used.
#undef macro_identifier |
In particular, it is useful if you need to define the same macro in different ways in different parts of the code. If the identifier specified in #define has already been registered somewhere in earlier lines of code (by another #define directive), then the old definition is replaced with the new one, and the preprocessor generates the "macro redefinition" warning. The use of #undef avoids the warning while explicitly indicating the programmer's intention not to use a particular macro further down the code.
#undef cannot undefine predefined macros.