COMPILE (specify source to compile)

Top  Previous  Next


COMPILE(terminator [,expression])


Specifies a block of source code lines to be included in the compilation.


A string constant that marks the last line of a block of source code.


An expression allowing conditional execution of the COMPILE. The expression is an EQUATE whose value is zero or one, EQUATE = integer, or any of the other supported comparison operators.

The COMPILE directive specifies a block of source code lines to be included in the compilation. The included block begins with the COMPILE directive and ends with the line that contains the same string constant as the terminator. The entire terminating line is included in the COMPILE block.

The optional expression parameter permits conditional COMPILE. The form of the expression is fixed. It is the label of an EQUATE statement, or a Conditional Switch set in the Project System, and may be followed by an equal sign = or conditional operator and an integer constant.

The following conditional operators are now supported:

Expressions may be one of the following forms:







<integer constant>



<integer constant>



<integer constant>



<integer constant>



<integer constant>



<integer constant>


The code between COMPILE and the terminator is compiled only if the expression is true. If the expression contains an EQUATE that has not yet been defined, then the referenced EQUATE is assumed to be zero (0).

Although the expression is not required, COMPILE without an expression parameter is not necessary because all source code is compiled unless explicitly omitted. COMPILE and OMIT are opposites.


OMIT('***',_WIDTH32_)            !OMIT only if application is 32-bit




COMPILE('***',_WIDTH32_)         !COMPILE only if application is 32-bit





COMPILE('EndOfFile',OnceOnly = 0) !COMPILE only the first time encountered because the

OnceOnly EQUATE(1)                ! OnceOnly EQUATE is defined after the COMPILE that

                                 ! references it, so a second pass during the same

                                 ! compilation will not re-compile the code

Demo EQUATE(1)                    !Specify the Demo EQUATE value


COMPILE('EndDemoChk',Demo = 1)   !COMPILE only if Demo equate is turned on

 DO DemoCheck                    !Check for demo limits passed

! EndDemoChk                     !End of conditional COMPILE code

! EndOfFile


!The following example below shows how OMIT and COMPILE can be nested

COMPILE ('**32bit**',_width32_) !outer COMPILE


COMPILE ('*debug*',_debug_)

DEBUGGER::BUTTONLIST Equate('&Continue|&Halt|&Debug')

!end- COMPILE ('*debug*',_debug_)


OMIT ('*debug*',_debug_)

DEBUGGER::BUTTONLIST Equate('&Continue|&Halt')

!end- OMIT ('*debug*',_debug_)


!end- COMPILE ('**32bit**',_width32_) !end outer COMPILE


OMIT ('**32bit**',_width32_)

DEBUGGER::BUTTONLIST Equate('&Continue|&Halt')

!end- OMIT ('**32bit**',_width32_)


The compiler reads and parses source/include files by blocks. If the end of an OMIT/COMPILE block (terminator string) is found in the current block, the compiler either with skip the text up to terminator or will continue to parse the file - depending on whether you are using OMIT or COMPILE and what condition. If the terminator string is found within the current block and parsing is continuing, nested OMIT/COMPILE statements are allowed. If the terminator string is not found, nested OMIT/COMPILE statement in this block is not allowed.

In summary, nesting of OMIT/COMPILE statements is dependent on the current compiler block. Use of conditions in OMIT/COMPILE statements and possibility to define complex conditions as EQUATEs are allowed to avoid excessive nesting of OMIT/COMPILE statements.

See Also:

Predefined Compiler Flags