HP OpenVMS Systems Documentation

Content starts here

HP COBOL
User Manual


Previous Contents Index

Hewlett-Packard recommends that you not name an HP COBOL program "main."

If you have a C routine named "main," you can work around this problem by having the "main" routine directly call the HP COBOL initialization routine, cob_init. The cob_init routine interface (in C) is as follows:


   void cob_init (         /* init the RTL */
       int argc,           /* argument count */
       char **argv,        /* arguments */
       char **envp         /* environment variable pointers */ )

1.1.2 Compiling an HP COBOL Program on Tru64 UNIX

Compilation does the following for you:

  • Detects errors in your program syntax
  • Displays compiler messages on your terminal screen
  • Generates machine language instructions from valid source statements
  • Groups the instructions into an object module for the linker ld

To compile your program, use the cobol command.

The COBOL Command Driver

The cobol command invokes a compiler driver that is the actual user interface to the HP COBOL compiler. It accepts a list of command flags and file names and causes one or more processors (compiler, assembler, or linker) to process each file.

After the HP COBOL compiler processes the appropriate files to create one or more object files, the compiler driver passes a list of files, certain flags, and other information to the cc compiler. After the cc compiler (the default C compiler on your system) processes relevant files and information, it passes certain information (such as .o object files) to the ld linker. The cobol command executes each processor; if any processor returns other than normal status, further processing is discontinued and the HP COBOL compiler displays a message identifying the processor (and its returned status, in hexadecimal) before terminating its own execution.

1.1.2.1 Format of the COBOL Command on Tru64 UNIX

The cobol command has the following format:


cobol [-flags [options]]... filename[.suffix] [filename[.suffix]]... [-flags [options]]...

-flags [options]

Indicates either special actions to be performed by the compiler or linker, or special properties of input or output files. For details about command-line flags, see Section 1.1.2.2. If you specify the -l string flag (which indicates libraries to be searched by the linker) or an object library file name, place it after the file names and after other flags.

filename.suffix

Specifies the source files containing the program units to be compiled, where the file name has a suffix that indicates the type of file used. The recognized COBOL suffix characters are .cob , .COB , .cbl , and .CBL .

Note that the compiler driver checks for a valid suffix on filename. If you omit suffix, or if it is not one of the types recognized by the cobol command, the file is assumed to be an object file and is passed directly to the linker.

An example cobol command line would be:


% cobol -v test.cob pas.o

This command specifies the following:

  • The -v flag displays the compilation and link passes with their arguments and files, including the libraries passed to ld .
  • The file test.cob is passed to the HP COBOL compiler for compilation. The resulting object file is then linked.
  • The object file pas.o is passed directly to the linker.

As an additional example, you might find that your compiler command lines are getting rather long, as shown in the following example:


% cobol -rsv foreign_extensions -flagger high_fips -warn information zeroes.cob

To work around this, you may truncate compiler flag options (arguments) to their shortest unambiguous form, as follows:


% cobol -rsv for -flagger high -warn info zeroes.cob

1.1.2.2 COBOL Command Flags

Flags to the cobol command affect how the compiler processes a file. The simplest form of the cobol command is often sufficient.

If you compile parts of your program (compilation units) using multiple cobol commands, flags that affect the execution of the program should be used consistently for all compilations, especially if data will be shared or passed between procedures.

For a complete list of HP COBOL flags, see Table 1-2. For more information about the HP COBOL flags, access the reference (man) page for COBOL at the Tru64 UNIX system prompt. For example:


%  man cobol

Table 1-2 HP COBOL Command Flags on Tru64 UNIX
Flag Default
-align [padding] off
-ansi off
-arch -arch generic
-arithmetic native -arithmetic native
-arithmetic standard -arithmetic native
-C off
-c on
-call_shared on
-check all off
-check [no]bounds -check nobounds
-check [no]decimal -check nodecimal
-check [no]perform -check noperform
-check none on
-conditionals [selector] off
-convert [no]leading_blanks -convert noleading_blanks
-copy off
-copy_list off
-cord off
-cross_reference off
-cross_reference alphabetical off
-cross_reference declared off
-D num off
-display_formatted off
-feedback file off
-fips 74 off
-flagger [option] off
-granularity byte ,
-granularity long ,
-granularity quad
-granularity quad
-g0 off
-g1 on
-g2 or -g off
-g3 off
-include off
-K off
-L off
-L dir off
-list off
-l string off
-mach or -machine_code off
-map off
-map alphabetical off
-map declared off
-math_intermediate cit3 ,
-math_intermediate cit4 ,
-math_intermediate float
-math_intermediate float
-names as_is ,
-names lower ,
-names lowercase ,
-names upper ,
-names uppercase
-names lowercase
-nationality japan ,
-nationality us
-nationality us
-nolocking off
-noobject off
-non_shared -call_shared
-nowarn off
-O0 off
-O1 off
-O2 off
-O3 off
-O4 or -O on
-o output a.out
-p0 on
-p1 or -p off
-relax_key_checking or -rkc off
-rsv [no]200x -rsv no200x
-rsv [no]foreign_extensions -rsv noforeign_extensions
-rsv [no]xopen -rsv xopen
-seq or -sequence_check off
-shared -call_shared
-show code off
-show copy off
-show xref off
-std or -std 85 on
-std [no]mia -std nomia
-std [no]syntax -std nosyntax
-std [no]v3 -std nov3
-std [no]xopen -std xopen
-T num off
-taso off
-tps off
-trunc off
-tune -tune generic
-V off
-v off
-w off
-warn -warn other
-warn all off
-warn [no]information -warn noinformation
-warn [no]other -warn other
-warn none off
-xref, -xref_stdout off


Previous Next Contents Index