Tru64 UNIX

Tru64 UNIX

Compaq C Language Reference Manual

Order Number: AA--RH9NB--TE

April 2000

This document is the language reference manual for Compaq C.

Software Version: Compaq C Version 6.1 for Tru64 UNIX Version 5.0A or higher

Compaq C Version 6.2 for OpenVMS Systems

Compaq C Version 6.2 for Linux Alpha

Compaq Computer Corporation
Houston, Texas

Copyright 2000 Compaq Computer Corporation

COMPAQ, VAX, and the Compaq logo Registered in U.S. Patent and Trademark Office. Tru64 and OpenVMS are trademarks of Compaq Information Technologies Group, L.P. UNIX is a trademark of The Open Group. All other product names mentioned herein may be trademarks or registered 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 publication is subject to change without notice and is provided "as is" without warranty of any kind. The entire risk arising out of the use of this information remains with recipient. In no event shall Compaq be liable for any direct, consequential, incidental, special, punitive, or other damages whatsoever (including without limitation, damages for loss of business profits, business interruption or loss of business information), even if Compaq has been advised of the possibility of such damages. The foregoing shall apply regardless of the negligence or other fault of either party and regardless of whether such liability sounds in contract, negligence, tort, or any other theory of legal liability, and notwithstanding any failure of essential purpose of any limited remedy.

The limited warranties for Compaq products are exclusively set forth in the documentation accompanying such products. Nothing herein should be construed as constituting a further or additional warranty.

Contents Index


This manual provides reference information for using the Compaq C language on Compaq systems. Compaq C is an ISO/ANSI-compliant C compiler for Compaq OpenVMStm VAX® and Compaq OpenVMS Alpha systems, Compaq Tru64tm UNIX® systems, and Linux Alpha systems. Tru64 UNIX runs on Alpha processors.

Compaq has changed the name of its UNIX operating system from DIGITAL UNIX to Tru64 UNIX.

Compaq C is compliant with the International Standards Organization (ISO) C Standard (ISO 9899:1990[1992]), formerly the American National Standard for Information Systems-Programming Language C (document number: X3.159-1989). By the use of command-line options, Compaq C is compatible with older dialects of C, including common usage C (Kernighan and Ritchie C) and VAX C.

This manual is based on the ISO C Standard (ISO 9899:1990[1992]), formerly the ANSI X3J11 committee's standard for the C programming language (called the ANSI C standard in this manual). 1 All library functions and language extensions to the ANSI C standard are also described.

You may send comments or suggestions regarding this manual or any Compaq C document by sending electronic mail to the following Internet address:


1 Compaq would like to thank CBEMA and its Accredited Standards Committee X3 for use of the material derived in whole or in part from the American National Standard Programming Language C. The ANSI C standard may be purchased from the ANSI Sales Department by calling the United States telephone number 1-212-642-4900.

Intended Audience

This manual is intended for programmers who need reference information on the Compaq C (formerly DEC C) language. There is little task-oriented material or platform-specific material in this manual; for that type of information, see your platform-specific Compaq C documentation (user's guide and online help for OpenVMS systems, programmer's guide and manpages for Tru64 UNIX systems.)

Purpose of the ANSI Standard

The ANSI C standard was developed by a committee of program developers and knowledgeable C users to address the problems caused by inexact specification of the C language. These problems were primarily related to portability of programs between different types of machines. The committee analyzed the language for areas where its syntax and semantics were vague or indeterminate, and then chose precise definitions for those C constructs. The result is an unambiguous, machine-independent definition.

The ANSI C standard states that it:

" specifies the form and establishes the interpretation of programs expressed in the programming language C. [The standard's] purpose is to promote portability, reliability, maintainability, and efficient execution of C language programs on a variety of computing systems. "

The standard specifies:

The ANSI C standard does not specify:

New and Changed Features

This manual was revised for Compaq C Version 6.2 to reflect the following new features. Note that Tru64 UNIX Version 5.0A is shipped with Version 6.1 of the C compiler and, therefore, does not include the listed features, except for the compiler name change.

Manual Structure

This manual has the following chapters and appendixes:

Chapter 1 describes the elements of the C language.

Chapter 2 discusses some of the basic concepts underlying the C language.

Chapter 3 explains Compaq C data types and type qualifiers.

Chapter 4 describes the declaration of identifiers in Compaq C. The declaration of constants, variables, structures, unions, pointers, and arrays is covered.

Chapter 5 describes function calls, function declarations, function definitions, function parameters, and function arguments.

Chapter 6 discusses the types of expressions you can build in C. It also explains the effects of operators available in C, including unary, binary, conditional, primary, and postfix operators.

Chapter 7 describes the C statements that provide flow control, conditional executions, looping, and interruption.

Chapter 8 explains the purpose of the C preprocessor directives and predefined macros.

Chapter 9 lists and describes the functions, macros, and types in the ANSI C standard library, arranged by header file.

Appendix A provides a syntax summary of all C language constructs.

Appendix B describes the extent of the ANSI conformance of Compaq C, including exceptions and extensions to the standard.

Appendix C provides the ASCII octal, decimal, and hexadecimal equivalents for each character in the ASCII character set.

Appendix D lists the common C extensions supported by Compaq C using the common C compatibility option.

Appendix E lists the VAX C extensions supported by Compaq C using the VAX C compatibility option.

Associated Documents

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


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

Conventions Used in This Document

Convention Meaning
OpenVMS systems Refers to OpenVMS VAX and OpenVMS Alpha systems unless otherwise specified.
[Return] The symbol [Return] represents a single stroke of the Return key on a terminal.
[Ctrl/X] The symbol [Ctrl/X], where X represents a terminal control character, represents holding down the Ctrl key while pressing the specified terminal character key.
Compaq C also allows ... Compaq C extensions to the ANSI C standard are shown in teal blue in the HTML version of the manual.
float x;
x = 5;
A vertical ellipsis indicates that not all of the text of a program or program output is shown. Only relevant material is shown in the example.
option,... A horizontal ellipsis indicates that additional parameters, options, or values can be entered. A comma preceding the ellipsis indicates that successive items must be separated by commas.
syntax opt Optional syntax elements are indicated with the subscripted abbreviation opt. Isolated syntax diagrams in individual sections of this manual may require reference to Appendix A to determine the complete syntax for a construct. For instance, the ANSI C standard syntax includes a constant as a potential assignment-expression.
storage-class-specifier :
In syntax definitions, items appearing on separate lines are mutually exclusive alternatives.
The auto storage class...
The fprintf function...
Monospaced type identifies language keywords, the names of independently compiled external functions and files, syntax summaries, and references to variables or identifiers introduced in an example.

Reader's Comments

Compaq welcomes any comments and suggestions you have on this and other Tru64 UNIX manuals. You can send your comments in the following ways:

Please include the following information along with your comments:

The Tru64 UNIX Publications group cannot respond to system problems or technical support inquiries. Please address technical questions to your local system vendor or to the appropriate Compaq technical support office. Information provided with the software media explains how to send problem reports to Compaq.

Next Contents Index