Tru64 UNIX Compaq C Language Reference Manual Order Number: AA–RH9NC–TE August 2000 This document is the language reference manual for Compaq C. Revision Update Information: This revised manual supersedes the DEC C Language Reference Manual (Order No. AA–RH9NB–TE). Software Version: Compaq C for Tru64 UNIX Version 5.1 or higher Compaq C Version 6.2 for OpenVMS Systems Compaq C Version 6.2 for Linux Alpha Compaq Computer Corporation Houston, Texas First Printing, February 1991 Revised, November 1992 Revised, November 1995 Revised, March 1996 Revised, May 1997 Revised, February 1998 Revised, December 1998 Revised, November 1999 Revised, April 2000 Revised, July 2000 Copyright 2000 Compaq Computer Corporation COMPAQ, VAX, and the Compaq logo Registered in U.S. Patent and Trademark Office. Tru64, Alpha, 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. This document was prepared using VAX DOCUMENT Version 2.1. Contents Preface ..................................................... xiii 1 Lexicon 1.1 Character Set ........................................ 1–3 1.1.1 Trigraph Sequences ................................ 1–5 1.1.2 Digraph Sequences ................................. 1–6 1.2 Identifiers .......................................... 1–6 1.3 Comments .......................................... 1–8 1.4 Keywords ........................................... 1–8 1.5 Operators ........................................... 1–10 1.6 Punctuators ......................................... 1–11 1.7 String Literals ....................................... 1–12 1.8 Constants ........................................... 1–13 1.8.1 Integer Constants ................................. 1–13 1.8.2 Floating-Point Constants . ........................... 1–15 1.8.3 Character Constants ............................... 1–16 1.8.3.1 Wide Characters ................................ 1–17 1.8.3.2 Multibyte Characters . ........................... 1–17 1.8.3.3 Character Escape Sequences . ................... 1–18 1.8.3.4 Numeric Escape Sequences ....................... 1–19 1.8.4 Enumeration Constants . ........................... 1–20 1.9 Header Files ........................................ 1–20 1.10 Limits . ........................................... 1–21 1.10.1 Translation Limits ................................. 1–21 1.10.2 Numerical Limits .................................. 1–22 1.10.3 Character Display ................................. 1–22 iii 2 Basic Concepts 2.1 Blocks ............................................. 2–2 2.2 Compilation Units .................................... 2–3 2.3 Scope .............................................. 2–3 2.3.1 File Scope ........................................ 2–4 2.3.2 Block Scope ...................................... 2–4 2.3.3 Function Scope .................................... 2–5 2.3.4 Function Prototype Scope ............................ 2–5 2.4 Visibility ............................................ 2–6 2.5 Side Effects and Sequence Points . ........................ 2–6 2.6 Incomplete Type ...................................... 2–8 2.7 Compatible and Composite Types . ........................ 2–9 2.8 Linkage ............................................ 2–11 2.9 Tentative Definitions . ................................ 2–13 2.10 Storage Classes ...................................... 2–13 2.10.1 The auto Class .................................... 2–14 2.10.2 The register Class . ................................ 2–15 2.10.3 The static Class . ................................ 2–15 2.10.4 The extern Class . ................................ 2–15 2.11 Storage-Class Modifiers ................................ 2–16 2.11.1 The _ _inline Modifier .............................. 2–17 2.11.2 The inline Modifier ................................ 2–17 2.11.2.1 Example—Using the inline Function Specifier . ....... 2–19 2.11.3 The _ _forceinline Modifier . ........................ 2–21 2.11.4 The _ _align Modifier ............................... 2–21 2.12 Forward References . ................................ 2–22 2.13 Tags............................................... 2–22 2.14 lvalues and rvalues . ................................ 2–24 2.15 Name Spaces ........................................ 2–25 2.16 Preprocessing ........................................ 2–25 2.17 Type Names . ........................................ 2–26 3 Data Types 3.1 Data Sizes . ........................................ 3–4 3.2 Integral Types ....................................... 3–5 3.2.1 Non-Character Types ............................... 3–6 3.2.2 Character Types . ................................ 3–7 3.3 Floating-Point Types . ................................ 3–8 3.4 Derived Types ....................................... 3–8 3.4.1 Function Type .................................... 3–9 3.4.2 Pointer Type ...................................... 3–9 iv 3.4.3 Array Type ....................................... 3–10 3.4.4 Structure Type . ................................... 3–11 3.4.5 Union Type . ................................... 3–12 3.5 void Type ........................................... 3–14 3.6 Enumerated Types . ................................... 3–15 3.7 Type Qualifiers ....................................... 3–16 3.7.1 const Type Qualifier ................................ 3–17 3.7.2 volatile Type Qualifier . ........................... 3–18 3.7.3 _ _unaligned Type Qualifier .......................... 3–20 3.7.4 _ _restrict Type Qualifier . ........................... 3–21 3.7.4.1 Rationale . ................................... 3–21 3.7.4.1.1 Aliasing ................................... 3–21 3.7.4.1.2 Library Examples ........................... 3–22 3.7.4.1.3 Overlapping Objects .......................... 3–23 3.7.4.1.4 Restricted Pointer Prototype for memcpy .......... 3–24 3.7.4.2 Formal Definition of the _ _restrict Type Qualifier ...... 3–24 3.7.4.3 Examples . ................................... 3–26 3.7.4.3.1 File Scope Restricted Pointers .................. 3–26 3.7.4.3.2 Function Parameters ......................... 3–27 3.7.4.3.3 Block Scope ................................ 3–27 3.7.4.3.4 Members of Structures ........................ 3–28 3.7.4.3.5 Type Definitions . ........................... 3–28 3.7.4.3.6 Expressions Based on Restricted Pointers ......... 3–29 3.7.4.3.7 Assignments between Restricted Pointers ......... 3–30 3.7.4.3.8 Assignments to Unrestricted Pointers . .......... 3–31 3.7.4.3.9 Ineffective Uses of Type Qualifiers ............... 3–31 3.7.4.3.10 Constraint Violations ......................... 3–32 3.8 Type Definition ....................................... 3–32 4 Declarations 4.1 Declaration Syntax Rules ............................... 4–1 4.2 Initialization ........................................ 4–4 4.3 External Declarations ................................. 4–7 4.4 Declaring Simple Objects ............................... 4–9 4.4.1 Initializing Simple Objects ........................... 4–10 4.4.2 Declaring Integer Objects . ........................... 4–10 4.4.3 Declaring Character Variables ........................ 4–10 4.4.4 Declaring Floating-Point Variables . ................... 4–11 4.5 Declaring Enumerations ............................... 4–11 4.6 Declaring Pointers . ................................... 4–12 4.6.1 Declaring void Pointers . ........................... 4–14 4.6.2 Initializing Pointers ................................ 4–15 v 4.7 Declaring Arrays ..................................... 4–15 4.7.1 Initializing Arrays . ................................ 4–18 4.7.2 Pointers and Arrays ................................ 4–21 4.7.3 Variable-Length Arrays ............................. 4–22 4.8 Declaring Structures and Unions . ........................ 4–23 4.8.1 Similarities Between Structures and Unions ............. 4–26 4.8.2 Differences Between Structures and Unions ............. 4–27 4.8.3 Bit Fields .......................................
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages332 Page
-
File Size-