When and How to Use >>IMP OPTION
Estimated Reading Time: 2 MinutesIn many COBOL applications, individual programs often require different compiler options. Some modules may need special flags, while others must avoid certain options entirely.
Typically, compiler options are defined in a compiler properties file or configured directly in the IDE’s compiler command line. However, this approach forces you to modify global settings every time a single program needs unique compilation behavior. Over time, this becomes error‑prone and disrupts the workflow for the rest of the application.
To avoid constantly changing global settings, COBOL provides the compiler directive: >>IMP OPTION "String". String is a quoted text value containing the compiler options you want applied or not applied only to that specific program. This allows you to embed program‑specific compilation rules directly in the source code, ensuring the correct options are always used without modifying project‑wide configuration files.
For example, suppose one program must always be compiled with the -dz option, and must never be compiled with -di. Instead of adjusting the global compiler settings each time, you can place the following directive at the very beginning of the program:
>>IMP OPTION "-dz -no-di"
This ensures:
- -dz is always applied when compiling this program
- -di is explicitly disabled
- No changes are required in compiler properties file, batch scripts, or the IDE settings
- The program remains self‑contained and portable, because its compilation requirements travel with the source code
Another example would be to use the “-brand” compile switch introduced in 2024R2. Suppose you want every compilation of a particular program to include a timestamp or version marker. You can embed this information directly into the program using -brand:
>>IMP OPTION "-brand=Last modified: 2026-07-28"
There is more information about this directive in isCOBOL’s documentation in the SDK User’s Guide under Compiler and Runtime : Compiler : Compiler Directives : IMP OPTION Directive.