The #define Conditional Directive

The #define directive is used to include a conditional identifier into a source file. When defined, the identifier can be used in all the classes contained within the source file. The directive must be placed at the top of the source file, with only comments and other conditional compilation directives preceding it.

By convention, the value of the identifier declared by the #define directive will always be true.

Syntax

#define <identifier>

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

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

    #define DEBUG  // DEBUG evaluates as true.
    
    #if DEBUG
        // code to be included
    #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.