Using the #pragma runopts preprocessor directive

You can use the #pragma runopts preprocessor directive to specify Language Environment® runtime options. You can also use #pragma runopts to specify the runtime options ARGPARSE, ENV, PLIST, REDIR, and EXECOPS, which have matching compiler options. If you specify the compiler option, it takes precedence over the #pragma runopts directive.

When the runtime option EXECOPS is in effect, you can specify runtime options at execution time, as previously described. These options override runtime options that you compiled into the program by using the #pragma runopts directive.

You can specify multiple runtime options per directive or multiple directives per compilation unit. If you want to specify the ARGPARSE or REDIR options, the #pragma runopts directive must be in the same compilation unit as main(). Neither runtime option has an effect on programs invoked under the z/OS® shell. This is because the shell program handles the parsing and redirection of command line arguments within that environment. Even though you can specify this directive in multiple compilation units, the specification that will take effect depends on the order of linking. It is advisable to specify it only once, and in the same compilation unit as main().

When you specify multiple instances of #pragma runopts in separate compilation units, the compiler generates a CSECT for each compilation unit that contains a #pragma runopts directive. When you link multiple compilation units that specify #pragma runopts, the linkage editor takes only the first CSECT, thereby ignoring your other option statements. Therefore, you should always specify your #pragma runopts directive in the same source file that contains the function main().

For more information on the #pragma runopts preprocessor directive, see z/OS XL C/C++ Language Reference.