DEC C

DEC C

User's Guide for OpenVMS Systems

Order Number: AA--PUNZG--TK


February 1998

This guide describes using the DEC C compiler on OpenVMS systems. It contains information on DEC C program development in the OpenVMS environment, DEC C features specific to OpenVMS systems, and cross-system portability concerns.

Revision Update Information: This revised guide supersedes the
DEC C User's Guide for OpenVMS Systems (Order No. AA--PUNZF--TK)

Software Version: DEC C Version 5.7 for OpenVMS Systems

Digital Equipment Corporation
Maynard, Massachusetts

The information in this document is subject to change without notice and should not be construed as a commitment by Digital Equipment Corporation. Digital Equipment Corporation assumes no responsibility for any errors that may appear in this document.

The software described in this document is furnished under a license and may be used or copied only in accordance with the terms of such license.

No responsibility is assumed for the use or reliability of software on equipment that is not supplied by Digital Equipment Corporation or its affiliated companies.

Restricted Rights: Use, duplication, or disclosure by the U.S. Government is subject to restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in Technical Data and Computer Software clause at DFARS 252.227-7013.

Printed in U.S.A.

All rights reserved. 0

The following are trademarks of Digital Equipment Corporation: DEC, DECnet, DECtalk, DECthreads, Digital, OpenVMS, RMS, ULTRIX, VAX, VAX C, CDD/Repository, VAX DOCUMENT, VMS, and the DIGITAL logo.

The following are third-party trademarks:

Microsoft is a registered trademark and Visual C++ is a trademark of Microsoft Corporation.

UNIX is a registered trademark in the United States and other countries licensed exclusively through X/Open Company Ltd.

IEEE is a registered trademark of the Institute of Electrical and Electronics Engineers, Inc.

This document is available on CD-ROM.

This document was prepared using VAX DOCUMENT, Version V3.2-1a.

Contents Index


Preface

This guide contains the information necessary for developing and debugging DEC C programs on the OpenVMS operating system. DEC C is compliant with the International Standards Organization (ISO) C Standard (ISO 9899:1990[1992]), 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. DEC C is an ANSI compliant C compiler for the OpenVMS operating system on VAX and Alpha processors and for the Digital UNIX operating system on Alpha processors. Through use of command-line options, DEC C is compatible with older dialects of C, including common usage C and VAX C.

This guide also includes DEC 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 DEC C Run-Time Library Reference Manual for OpenVMS Systems.

You may send comments or suggestions regarding this guide or any DEC C document by filling out one of the Reader's Comments forms at the back of this guide or by sending electronic mail to the following Internet address:

decc_docs@bookie.enet.dec.com

Intended Audience

This guide is intended for experienced programmers who need to develop DEC C programs on OpenVMS systems, for users who need to know the difference between DEC 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.

Document Structure

This guide has the following chapters and appendixes:

Associated Documents

You may find the following documents useful when programming in DEC C:

Note

1 Brian W. Kernighan and Dennis M. Ritchie, The C Programming Language, Second Edition (Englewood Cliffs, New Jersey: Prentice Hall, 1988).

Conventions Used in this Document

Table 1 lists the conventions used in this guide.

Table 1 Conventions Used in this Guide
Convention Meaning
[Return] The symbol [Return] represents a single stroke of the Return key on a terminal.
Ctrl/X The symbol Ctrl/X, where the letter X represents a terminal control character, is generated by holding down the Ctrl key while pressing the key of the specified terminal character.
switch statement
fprintf function
auto storage class
In syntax definitions, items appearing in monospaced type identify language keywords and the names of OpenVMS and DEC C Run-Time Library functions.
arg1 Italic type indicates a placeholder, such as an argument or parameter name, and the introduction of new terms.
$ run cprog [return] Interactive examples show user input in boldface type.
float x;
.
.
.
x = 5;
A vertical ellipsis indicates that not all of the text of a program or program output is illustrated. Only relevant material is shown in the example.
option,... A horizontal ellipsis indicates that additional parameters, options, or values can be entered. A comma that precedes the ellipsis indicates that successive items must be separated by commas.
[output-source,...] Square brackets, in function synopses and a few other contexts, indicate that a syntactic element is optional. Square brackets are not optional, however, when used to delimit a directory name in an OpenVMS file specification or when used to delimit the dimensions of an array in DEC C source code.
sc-specifier ::=
auto
static
[extern]
register
In syntax definitions, items appearing on separate lines are mutually exclusive alternatives.
{a|b} Braces surrounding two or more items separated by a vertical bar (|) indicate a choice; you must choose one of the two syntactic elements.
<ucDelta symbol> A delta symbol is used in some contexts to indicate a single ASCII space character.

Platform Labels

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:
Label Explanation
(ALPHA ONLY) Specific to an Alpha processor running the OpenVMS operating system.
(VAX ONLY) Specific to a VAX processor running the OpenVMS operating system.

New and Changed Features

DEC C Version 5.7 includes the following new features:

Also see Appendix A for a summary of features that distinguish DEC C for OpenVMS Systems from VAX C Version 3.2.


Chapter 1
Developing DEC C Programs

This chapter describes the following information about developing DEC C programs on an OpenVMS system:

1.1 DCL Commands for Program Development

This section provides a brief overview of the DCL commands used for program development. The following sections provide more detailed information about these topics.

Figure 1-1 shows the basic steps in DEC C program development.

Figure 1-1 DCL Commands for Developing Programs


To create a DEC C source program at DCL level, you must invoke a text editor. In Figure 1-1, the EDIT command invokes the default editor EDT to create the source program AVERAGE.C. You can use another editor, such as the DEC Text Processing Utility (DECTPU) or the DEC Language-Sensitive Editor (LSE). (LSE is a product that must be purchased separately; see Appendix C for more information.) A file type of C is used to indicate that you are creating a DEC C source program. C is the conventional file type for all DEC C source programs.

When you compile your program with the CC command, you do not have to specify the file type; by default, DEC C searches for files with a file type of C.

If your source program compiles successfully, the DEC C compiler creates an object file with the file type OBJ.

However, if the DEC C compiler detects errors in your source program, the system displays each error on your screen and then displays the DCL prompt. You can then reinvoke your text editor to correct each error.

You can specify command qualifiers on the CC command. Command qualifiers cause the DEC C compiler to perform additional actions. In the following example, the /LIST qualifier causes the DEC C compiler to produce the listing file AVERAGE.LIS:


$ 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 DEC 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.

After producing the executable image file, use the RUN command to execute your program.

1.2 Creating a DEC C Program

To create and modify a DEC C program, you must invoke a text editor. The OpenVMS system provides you with two text editors: EDT and the DEC Text Processing Utility (DECTPU). The following section discusses DECTPU. See the OpenVMS EDT Reference ManualOpenVMS EDT Reference Manual for more information on EDT.

1.2.1 Using DECTPU

DECTPU is a high-performance, programmable utility. It provides two editing interfaces: the Extensible VAX Editor (EVE), described in the following section, and the DECTPU EDT Keypad Emulator. You can also create your own interfaces.

Like EDT, DECTPU provides you with an online help facility that you can access during your editing session. When you invoke DECTPU 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.

Unlike EDT, DECTPU provides multiple windows. This feature allows you to view two files on your screen at the same time.

1.2.2 The EVE Interface to DECTPU

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.

For more information on using EVE, see the Guide to VMS Text Processing.

1.3 Compiling a DEC C Program

The DEC C compiler performs the following functions:

The following sections discuss the CC command and its qualifiers.

1.3.1 The CC Command

To invoke the DEC C compiler, enter the CC command at the DCL prompt ($). The CC command has the following format:

CC[/qualifier...][ file-spec [/qualifier...]],...

Note (VAX ONLY)

This note applies to OpenVMS VAX systems that have both DEC C and VAX C installed.

The CC command is used to invoke either the VAX C or DEC C compiler. If the DEC 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 DEC 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.

/qualifier

An 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-spec

An 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 DEC 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 DEC 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 DEC 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.

Note

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 runtime 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 


Next Contents Index