
C Language Reference Manual 007–0701–130 St. Peter’s Basilica image courtesy of ENEL SpA and InfoByte SpA. Disk Thrower image courtesy of Xavier Berenguer, Animatica. Copyright © 1999 Silicon Graphics, Inc. All Rights Reserved. This document or parts thereof may not be reproduced in any form unless permitted by contract or by written permission of Silicon Graphics, Inc. LIMITED AND RESTRICTED RIGHTS LEGEND Use, duplication, or disclosure by the Government is subject to restrictions as set forth in the Rights in Data clause at FAR 52.227-14 and/or in similar or successor clauses in the FAR, or in the DOD, DOE or NASA FAR Supplements. Unpublished rights reserved under the Copyright Laws of the United States. Contractor/manufacturer is Silicon Graphics, Inc., 1600 Amphitheatre Pkwy., Mountain View, CA 94043-1351. Autotasking, CF77, CRAY, Cray Ada, CraySoft, CRAY Y-MP, CRAY-1, CRInform, CRI/TurboKiva, HSX, LibSci, MPP Apprentice, SSD, SUPERCLUSTER, UNICOS, X-MP EA, and UNICOS/mk are federally registered trademarks and Because no workstation is an island, CCI, CCMT, CF90, CFT, CFT2, CFT77, ConCurrent Maintenance Tools, COS, Cray Animation Theater, CRAY APP, CRAY C90, CRAY C90D, Cray C++ Compiling System, CrayDoc, CRAY EL, CRAY J90, CRAY J90se, CrayLink, Cray NQS, Cray/REELlibrarian, CRAY S-MP, CRAY SSD-T90, CRAY SV1, CRAY T90, CRAY T3D, CRAY T3E, CrayTutor, CRAY X-MP, CRAY XMS, CRAY-2, CSIM, CVT, Delivering the power . ., DGauss, Docview, EMDS, GigaRing, HEXAR, IOS, ND Series Network Disk Array, Network Queuing Environment, Network Queuing Tools, OLNET, RQS, SEGLDR, SMARTE, SUPERLINK, System Maintenance and Remote Testing Environment, Trusted UNICOS, and UNICOS MAX are trademarks of Cray Research, Inc., a wholly owned subsidiary of Silicon Graphics, Inc. DynaText and DynaWeb are registered trademarks of Inso Corporation. Gaussian is a trademark of Gaussian, Inc. OpenMP is a trademark of the OpenMP Architecture Review Board. Portions of this publication may have been derived from the OpenMP Language Application Program Interface Specification. Silicon Graphics and the Silicon Graphics logo are registered trademarks of Silicon Graphics, Inc. UNIX is a registered trademark in the United States and other countries, licensed exclusively through X/Open Company Limited. X/Open is a trademark of X/Open Company Ltd. The X device is a trademark of the Open Group. The UNICOS operating system is derived from UNIX® System V. The UNICOS operating system is also based in part on the Fourth Berkeley Software Distribution (BSD) under license from The Regents of the University of California. New Features C Language Reference Manual 007–0701–130 This revision of the C Language Reference Manual supports the 7.3 release of the MIPSpro compiler. See the cc(1) man page for changes or additions to command-line options. This manual contains the following additions and deletions: • Information about OpenMP C/C++ Application Program Interface (API) multiprocessing directives has been added. • Information about the auto-parallelizing option (APO) has been added; this information was taken from the MIPSpro Auto-Parallelizing Option Programmer’s Guide, which is no longer being revised. Detailed information can be found in the MIPSpro C and C++ Pragmas manual. • Details about the multiprocessing C/C++ compiler #pragma directives have been removed. See the MIPSpro C and C++ Pragmas manual for information about #pragma directives. Record of Revision Version Description 7.3 April 1999 This document has been updated to support the MIPSpro 7.3 release. 007–0701–130 i Contents Page About This Manual xv Related Publications . .................... xv Obtaining Publications . .................... xv Conventions . ......................... xvi Reader Comments ........................ xvii An Overview of ANSI C [1] 1 ANSI C . ......................... 1 Strictly Conforming Programs .................... 1 Name Spaces ......................... 1 Compiling ANSI Programs .................... 2 Guidelines for Using ANSI C .................... 2 Compiling Traditional C Programs . ............... 3 Helpful Programming Hints . .................... 3 Recommended Practices . .................... 3 Practices to Avoid . .................... 4 C Language Changes [2] 7 Preprocessor Changes . .................... 7 Replacement of Macro Arguments in Strings ............... 8 Token Concatenation . .................... 9 Changes in Disambiguating Identifiers . ............... 10 Scoping Differences . .................... 10 Name Space Changes . .................... 12 Changes in the Linkage of Identifiers . ............... 12 007–0701–130 iii C Language Reference Manual Page Types and Type Compatibility .................... 13 Type Promotion in Arithmetic Expressions . ............... 14 Type Promotion and Floating Point Constants ............... 15 Compatible Types . .................... 16 Argument Type Promotions .................... 17 Mixed Use of Functions . .................... 18 Function Prototypes . .................... 18 External Name Changes . .................... 19 Changes in Function Names .................... 19 Changes in Linker-Defined Names . ............... 20 Data Area Name Changes . .................... 20 Standard Headers ........................ 21 Lexical Conventions [3] 23 Comments . ......................... 23 Identifiers . ......................... 23 Keywords . ......................... 23 Constants . ......................... 24 Integer Constants . .................... 24 Character Constants . .................... 25 Special Characters . .................... 25 Trigraph Sequences (ANSI C Only) . ............... 26 Floating Constants . .................... 27 Enumeration Constants . .................... 27 String Literals ......................... 28 Operators . ......................... 28 Punctuators . ......................... 29 Meaning of Identifiers [4] 31 iv 007–0701–130 Contents Page Disambiguating Names . .................... 31 Scope . ......................... 31 Block Scope ........................ 31 Function Scope . .................... 32 Function Prototype Scope .................... 32 File Scope ......................... 32 Name Spaces ......................... 33 Name Space Discrepancies Between Traditional and ANSI C ......... 33 Linkage of Identifiers . .................... 34 Linkage Discrepancies Between Traditional and ANSI C . .......... 36 Storage Duration ........................ 37 Object Types . ......................... 38 Character Types ........................ 38 Integer and Floating Point Types ................... 38 Derived Types ........................ 40 void Type ......................... 40 Objects and lvalues ........................ 40 Operator Conversions [5] 43 Conversions of Characters and Integers . ............... 43 Conversions of Float and Double ................... 43 Conversion of Floating and Integral Types . ............... 44 Conversion of Pointers and Integers . ............... 44 Conversion of unsigned Integers ................... 44 Arithmetic Conversions . .................... 45 Integral Promotions . .................... 45 Usual Arithmetic Conversions ................... 45 Traditional C Conversion Rules . ............... 45 007–0701–130 v C Language Reference Manual Page ANSI C Conversion Rules .................... 46 Conversion of Other Operands .................... 47 Conversion of lvalues and Function Designators .............. 47 Conversion of void Objects .................... 47 Conversion of Pointers . .................... 47 Expressions and Operators [6] 49 Precedence and Associativity Rules in C . ............... 49 Primary Expressions . .................... 51 Postfix Expressions ........................ 51 Subscripts . ......................... 52 Function Calls ........................ 52 Structure and Union References ................... 54 Indirect Structure and Union References . ............... 54 postfix ++ and postfix - - ................... 54 Unary Operators ........................ 55 Address-of and Indirection Operators . ............... 55 Unary + and - Operators . .................... 56 Unary ! and ~ Operators . .................... 56 Prefix ++ and --Operators .................... 56 sizeof Unary Operator . .................... 57 Cast Operators ......................... 57 Multiplicative Operators . .................... 58 Additive Operators ........................ 59 Shift Operators ......................... 60 Relational Operators . .................... 60 Equality Operators ........................ 61 Bitwise AND Operator . .................... 62 Bitwise Exclusive OR Operator .................... 62 vi 007–0701–130 Contents Page Bitwise Inclusive OR Operator .................... 62 Logical AND Operator . .................... 62 Logical OR Operator . .................... 63 Conditional Operator . .................... 63 Assignment Operators . .................... 64 Assignment Using = (Simple Assignment) . ............... 65 Compound Assignment . .................... 65 Comma Operator ........................ 65 Constant Expressions . .................... 66 Integer and Floating Point Exceptions . ............... 67 Declarations [7] 69 Storage Class Specifiers . .................... 70 Type Specifiers ......................... 71 Structure and Union Declarations ................... 72 Bitfields . ......................... 75 Enumeration Declarations . .................... 76 Type Qualifiers ......................... 77 Declarators . ......................... 78 Meaning of Declarators
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages236 Page
-
File Size-