The #undef Conditional Directive

The #undef directive, as its name implies, is used to remove an identifier from a source file. The identifier need not be defined beforehand, and can be redefined again within the source file using the #define directive. The #undef directive must be placed at the top of the source file, with only comments and other conditional directives preceding it.

Syntax

#undef <identifier>

The identifier shown above can be up to 1024 characters in length. By convention, identifiers are usually composed of uppercase characters to clarify their usage.

The following example illustrates use of the #undef directive in a Java application:

    #undef DEBUG  // DEBUG evaluates to false
    
    #if DEBUG    // now set to false.
        // lines extracted at compile-time
    #endif

Note   The Visual J++ build process does not allow per-file build settings. This means that in order to turn on and off conditional identifiers within a single source file, the #define and #undef directives must be explicitly declared within each file.