HP OpenVMS SystemsC Programming Language
User's Guide for OpenVMS Systems
Order Number: AA--PUNZL--TK
This guide describes using the Compaq C compiler on OpenVMS systems. It contains information on Compaq C program development in the OpenVMS environment, Compaq C features specific to OpenVMS systems, and cross-system portability concerns.
This revised guide supersedes the
Software Version: Compaq C Version 6.5 for OpenVMS Alpha Systems
Compaq Computer Corporation
First Printing, November 1992
Revised, February 2002
© Copyright 2002 Compaq Information Technologies Group, L.P.
COMPAQ, the Compaq logo, VAX, Alpha, VMS, OpenVMS, and Tru64 are trademarks of Compaq Information Technologies Group, L.P. in the U.S. and/or other countries. Microsoft and Visual C++ are trademarks of Microsoft Corporation. UNIX is a trademark of The Open Group in the United States and other countries. All other product names mentioned herein may be trademarks of their respective companies.
Confidential computer software. Valid license from Compaq required for possession, use, or copying. Consistent with FAR 12.211 and 12.212, Commercial Computer Software, Computer Software Documentation, and Technical Data for Commercial Items are licensed to the U.S. Government under vendor's standard commercial license.
Compaq shall not be liable for technical or editorial errors or omissions contained herein. The information in this document is provided as is without warranty of any kind and is subject to change without notice. The warranties for Compaq products are set forth in the express limited warranty statements accompanying such products. Nothing herein should be construed as constituting an additional warranty.
This document is available on CD-ROM.
This document was prepared using DECdocument, Version V3.3-1e.
This guide contains the information necessary for developing and debugging Compaq C (formerly DEC C) programs on the OpenVMS operating system. Compaq C is compliant with the International Standards Organization (ISO) C Standard (ISO 9899:1990), formerly the American National Standard for Information (ANSI) Systems-Programming Language C (document number: X3.159-1989), called the ANSI C Standard in this guide. Compaq C is an ANSI compliant C compiler for the OpenVMS operating system on VAX and Alpha processors and for the Tru64 UNIX® operating system on Alpha processors. Through use of command-line options, Compaq C is compatible with older dialects of C, including common usage C and VAX C.
This guide also includes Compaq C language features specific to OpenVMS systems, as well as information about porting C programs to and from OpenVMS and other operating systems. For more information about porting programs to and from other operating systems, see the Compaq C Run-Time Library Reference Manual for OpenVMS Systems.
This guide is intended for experienced programmers who need to develop Compaq C programs on OpenVMS systems, for users who need to know the difference between Compaq C and other implementations, and for experienced C users who need to reference language information specific to OpenVMS systems. You should be familiar with one high-level language and should have some familiarity with the DIGITAL Command Language (DCL). If you are not familiar with or need to reference information about the DCL, see Chapter 1.
This guide has the following chapters and appendixes:
You may find the following documents useful when programming in Compaq C:
Conventions Used in this Document
Table 1 lists the conventions used in this guide.
A platform is a combination of operating system and hardware that provides a distinct environment. This guide contains information applicable to the OpenVMS operating system on both the VAX and Alpha architectures.
The information in this guide applies to both of these platforms, except when specifically labeled, as follows:
New and Changed Features
Compaq C Version 6.5 for OpenVMS Alpha contains the following new features and enhancements:
$ CC/LIST AVERAGE
For a complete description of all CC command qualifiers, see Section 1.3.4.
After your program has compiled successfully, invoke the OpenVMS Linker to create an executable image file. For example:
$ LINK AVERAGE
The linker uses the object file produced by Compaq C as input to produce an executable image file as output. (The executable image is a file containing program code that can be run on the system.)
You can specify command qualifiers with the DCL command LINK. For a complete list and explanation of all the command qualifiers available with the LINK command, see Section 1.4.2.
To create and modify a Compaq C program, you must invoke a text editor. The OpenVMS system provides you with two text editors: EDT and the OpenVMS Text Processing Utility (TPU). The following section discusses TPU. See the OpenVMS EDT Reference Manual for more information on EDT.
TPU is a high-performance, programmable utility. It provides two editing interfaces: the Extensible VAX Editor (EVE), described in the following section, and the TPU EDT Keypad Emulator. You can also create your own interfaces.
Like EDT, TPU provides you with an online help facility that you can access during your editing session. When you invoke TPU to create a file, a journal file is automatically created. You can use this journal file to recover your edits if the system fails during an editing session. To recover your edits, enter the EVE/RECOVER command.
EVE is an interactive text editor that allows you to execute common editing functions using the EVE keypad or to execute more advanced functions by entering commands on the EVE command line. The following command line invokes the EVE editor and creates the file PROG_1.C:
$ EDIT/TPU PROG_1.C
You can define a global symbol for the EDIT/TPU command by placing a symbol definition in your LOGIN.COM file. For example:
$ EVE == "EDIT/TPU"
After this command line is executed, you can type EVE at the DCL prompt followed by the name of the file you want to modify or create.
The Compaq C compiler performs the following functions:
To invoke the Compaq C compiler, enter the CC command at the DCL prompt ($). The CC command has the following format:
CC[/qualifier...][ file-spec [/qualifier...]],...
This note applies to OpenVMS VAX systems that have both Compaq C and VAX C installed.
The CC command is used to invoke either the VAX C or Compaq C compiler. If the Compaq C installation procedure detects that your system already has a VAX C compiler installed on it, the installer is given the option to specify which compiler gets invoked by default whenever the CC command verb is used. To invoke the compiler that is not the default, use the CC command with the appropriate qualifier: CC/DECC for the Compaq C compiler, or CC/VAXC for the VAX C compiler. Where the CC command appears in examples in this manual, CC/DECC is assumed to be the default.
/qualifierAn action to be performed by the compiler on all files or specific files listed. When a qualifier appears directly after the CC command, it affects all the files listed. When a qualifier appears after a file specification, it affects only the file that immediately precedes it. However, when files are concatenated, these rules do not apply.
file-specAn input source file that contains the program or module to be compiled. You are not required to specify a file type if you give your file a .C file extension; the Compaq C compiler adopts the default file type C.
You can include more than one file specification on the same command line by separating the file specifications with either a comma (,) or a plus sign (+). If you separate the file specifications with commas, you can control which source files are affected by each qualifier. In the following example, the Compaq C compiler creates an object file for each source file but creates only a listing file for the source files PROG_1 and PROG_3:
$ CC /LIST PROG_1, PROG_2/NOLIST, PROG_3
If you separate file specifications with plus signs, the Compaq C compiler concatenates each of the specified source files and creates one object file and one listing file. In the following example, only one object file is created, PROG_1.OBJ, and only one listing file is created, PROG_1.LIS. Both of these files are named after the first source file in the list, but contain all three modules.
$ CC PROG_1 + PROG_2/LIST + PROG_3
Any qualifiers specified for a single file within a list of files separated with plus signs affect all the files in the list. See the description of the /PLUS_LIST_OPTIMIZE qualifier for its affect on file concatenation.
Concatenating source files without using the /PLUS_LIST_OPTIMIZE qualifier (ALPHA ONLY) is not recommended because potential conflicts in the name space of declared objects can result in compilation errors or incorrect run-time behavior.
A more common use of plus-list concatenation is for specifying text libraries. You can specify the name of a text library on the CC command line to compile a source program. A text library is a file that contains text organized into modules indexed by a table. Text libraries have a .TLB default file extension. In the following example, text libraries A.TLB and B.TLB are made available for searching for text library modules during the compilation of source file TEST.C:
$ CC TEST.C + A.TLB/LIB + B.TLB/LIB