b98 Undefining Macros Contents|Index|Previous|Next
 

Undefining macros 

To undefine a macro means to cancel its definition. This is done with the #undef directive. #undef is followed by the macro name to be undefined.

Like definition, undefinition occurs at a specific point in the source file, and it applies starting from that point. The name ceases to be a macro name, and from that point on it is treated by the preprocessor as if it had never been a macro name. For clarification, use the following example.

This input expands into the following output. In this example, FOO had better be a variable or function as well as (temporarily) a macro, in order for the result of the expansion to be valid C code. The same form of #undef directive will cancel definitions with arguments or definitions that don’t expect arguments. The #undef directive has no effect when used on a name not currently defined as a macro. 0