Single Sourcing and Compiling Native COBOL Programs for 64-Bit

Restriction: The following information applies to native COBOL only.

When using the appropriate command line tools or IDE settings to compile to 64-bit, this is effectively setting a Compiler directive (P64) to indicate that the Compiler compiles your program for 64-bit. You are discouraged from setting this directive directly within your code, but you can use it in the following technique in order to create source code that can easily be compiled to 32- and 64-bit with minimal to no code changes.

The following conditional compilation construction can be used to compile code based on the presence of the P64 directive. See the $IF Statement in the Language Reference Manual for more details.

      $if P64 set
      *> perform 64-bit specific code
      *> perform 32-bit specific code

Conditional compilation techniques can also be used to create dual FCD programs, making the same source code compatible for environments where different FCD versions are required.