.IFDEF-.ELSE-.ENDC
Perform conditional processing
|
WSupported on Windows
|
USupported on Unix
|
VSupported on OpenVMS
|
NSupported in Synergy .NET
|
.IFDEF data_element [. . . source_1 . . .] [.ELSE . . . [source_2 . . .]] .ENDC
Arguments
data_ element
One of the following:
- A defined macro
- A data declaration (a field, record, or structure) in the current routine
- An enumeration (if compiling with -qrelaxed=ifdef)
- A data declaration in a class (if compiling with -qrelaxed=ifdef)
- A data declaration in a global structure (if compiling with -qrelaxed=ifdef)
source_1
(optional) One or more lines of source code.
source_2
(optional) One or more lines of source code.
Discussion
The .IFDEF compilation control directive indicates that the statements that follow are to be compiled if the specified data element has already been defined.
The source_1 lines of code are compiled only if the specified variable or identifier is defined prior to the .IFDEF directive. If the .ELSE directive is present, the source_2 lines of code are compiled only if the specified variable or identifier is not defined prior to the .IFDEF directive.
You can use one or more of the .ELSE, .IFT, .IFF, and .IFTF directives within an .IFDEF conditional block. These conditional compilation control directives can be nested.
The .ENDC directive must always close an .IFDEF conditional block. If .ENDC is not present, a warning is generated.
By default, data declarations in an .IFDEF directive must be local: a field, record, or structure in the current routine. If you want to use .IFDEF on global symbols (like enumerations, classes, and global structures), you must compile with the -qrelaxed=ifdef option.
Examples
The following example shows a simple conditional compilation control operation.
.define TTCHN ,1
.define DEBUG
proc
open(TTCHN, o, "tt:")
.
.
.
.ifdef DEBUG
writes(TTCHN, "Entering mod1") ;This code will be compiled.
.endc
The following example shows nesting of the .IFDEF conditional compilation control directive.
.define SHOWTABLES
.define SHOWTBLB
.define TTCHN ,1
proc
open(TTCHN, o, "tt:")
.
.
.
.ifdef SHOWTABLES
.ifdef SHOWTBLA
writes(TTCHN, "Table A") ;This code won't be compiled.
.endc
.ifdef SHOWTBLB
writes(TTCHN, "Table B") ;This code will be compiled.
.endc
.endc
