[an error occurred while processing this directive]

HP OpenVMS Systems Documentation

Content starts here

HP COBOL
User Manual


Previous Contents Index

1.1.2.8 Naming Output Files

To specify a file name (other than a.out ) for the executable image file, use the -o output flag, where output specifies the file name. You can also use the mv command to rename the file. The following command requests a file name of prog1.out for the source file test1.cob :


% cobol -o prog1.out test1.cob

Besides specifying the name of the executable image file, you can use the -o output flag to rename the object file if you specified the -c flag. If you specify the -c flag and omit the -o output flag, the name of the first specified file is used with a .o suffix substituted for the source file suffix.

1.1.2.9 Temporary Files

Temporary files created by the compiler or a preprocessor reside in the /tmp directory and are deleted (unless the -K flag is specified). You can set the environment variable TMPDIR to specify a directory to contain temporary files if /tmp is not acceptable.

To view the file name and directory where each temporary file is created, use the -v flag. To create object files in your current working directory, use the -c flag. Any object files ( .o files) that you specify on the cobol command line are retained.

1.1.2.10 Examples of the COBOL Command

The following examples show the use of the cobol command. Each command is followed by a description of the output files that it produces.


#1

% cobol -V aaa.cob bbb.cob ccc.cob
      

The HP COBOL source files aaa.cob , bbb.cob , and ccc.cob are compiled into temporary object files. The temporary object files are passed to the ld linker. The ld linker produces the executable file a.out . The -V flag causes the compiler to create the listing files aaa.lis , bbb.lis , and ccc.lis .

#2

% cobol -V *.cob
      

HP COBOL source files with file names that end with .cob are compiled into temporary object files, which are then passed to the ld linker. The ld linker produces the a.out file.

When the compilation completes, the cobol driver returns one of the following status values:

0---SUCCESS
1---FAILURE
2---SUBPROCESS_FAILURE ( cobol or cc )
3---SIGNAL

1.1.2.11 Other Compilers

You can compile and link multilanguage programs using a single cobol command.

The cobol command recognizes C or Assembler program files by their file suffix characters and passes them to the cc compiler for compilation. Before compilation, cc applies the cpp preprocessor to files that it recognizes, such as any file with a .c suffix.

Certain flags passed to cc are passed to the ld linker.

1.1.2.12 Interpreting Messages from the Compiler

The HP COBOL compiler identifies syntax errors and violations of language rules in the program. If the compiler finds any errors, it writes messages to the stderr output file and any listing file. If you enter the cobol command interactively, the messages are displayed on your terminal.

Compiler messages have the following format:


 cobol: severity: filename, line n, message-text
 [text-in-error]
 --------^

The pointer ( --^ ) indicates the exact place on the source line where the error was found. For example, the following error message shows the format and message text in a listing file when an END DO statement was omitted:


cobol: Severe: disp.cob, line 7: Missing period is assumed
        05 VAR-1 PIC X.
--------^

The severity level is one of the following:

Severe The compiler does not produce an object module. You must correct the error before you can compile the program to produce an object module.
Error The compiler makes an assumption about what you intended and continues. However, the compiler's assumption may not relate to your intention. Correct the error.
Warning The compiler attempts to correct the error in the statement, but you should verify that the compiler's action is acceptable. Otherwise, your program may produce unexpected results.
Informational This message usually appears with other messages to inform you of specific actions taken by the compiler. No action is necessary on your part.

Any messages issued during the compilation are inserted in the listing file. A listing file is useful for debugging the source code. Use the -V or -list flag to produce a listing; you may also use -cross_reference , -copy_list , -flagger , -machine_code , -map , and/or -warn , all of which affect the contents of the listing file.

Diagnostic messages provide information for you to determine the cause of an error and correct it. If the compiler creates a listing file, it writes the messages to the listing file.

1.1.3 Linking an HP COBOL Program on Tru64 UNIX

Once your program has compiled successfully, the system passes the resulting object file (which has the suffix .o by default) to the linker to create an executable image file. By default, the executable image file has the name a.out. (To change this default, specify -o filename on the cobol command line.) This file can be run on the Tru64 UNIX system.

The ld linker provides the following primary functions:

  • Generates appropriate information in the executable image for virtual memory allocation
  • Resolves symbolic references among object files being linked, including whether to search in archive or shared object libraries
  • Assigns values to relocatable global symbols
  • Performs relocation

The linker produces an executable program image with a default name of a.out.

When you enter a cobol command, the ld linker is invoked automatically unless a compilation error occurs or you specify the -c flag on the command line.


Previous Next Contents Index