Invoking a Preprocessor

Note: The Integrated Preprocessor is supported for native COBOL only.

The preprocessor is invoked by the Compiler, which is directed to do so by using the PREPROCESS directive. The general form of the directive is:

>>--.---.-.----.-PREPROCESS-.-"name".----------------.-.------.-.><
    +-/-+ |    +-P----------+       +-preproc-params-+ +-ENDP-+ |
          |                                                     |
          +-NO-.-PREPROCESS-.-----------------------------------+
               +-P----------+

where the parameters are:

name The name of the preprocessor
preproc-params One or more of the optional preprocessor parameters

You specify the directive when compiling a file you want preprocessed.

All parameters on the command line following the PREPROCESS directive and up to the end of the line, or the ENDP directive, are passed to the preprocessor without examination.

Note: It is advisable to use the ENDP COBOL directive to terminate the directives to pass to the preprocessor. Directives placed after ENDP pass to the COBOL compiler. Therefore, without the ENDP directive, compiler directives may continue to pass to the preprocessor rather than to the COBOL compiler.

In a similar manner to other Compiler directives, the PREPROCESS directive can be either placed in a directives file or included in a $SET statement within the source code. It should not be specified in more than one place. If it is in a $SET statement, it must be the first line in the source file.

Invoking Multiple Preprocessors

Multiple preprocessors are invoked by passing a preprocess directive to the preprocessor so that it calls the next preprocessor. It is the responsibility of the first preprocessor to call the second; this can then call a third, and so on. Preprocessors that are not written to allow this stack method can only be used as the last preprocessor in the stack.

To invoke several preprocessors, stack the directive:

   +---------------------------------------+
   V                                       |
>>----preprocess"name"-.----------------.--+---><
                       +-preproc-params-+
                        

For information on writing preprocessors to be used in this way, see the topic Multiple Preprocessors.