XL C/C++: Language Reference the Static Storage Class Specifier
Total Page:16
File Type:pdf, Size:1020Kb
IBM XL C/C++ for Blue Gene/Q, V12.1 Language Reference Ve r s i o n 12 .1 GC14-7364-00 IBM XL C/C++ for Blue Gene/Q, V12.1 Language Reference Ve r s i o n 12 .1 GC14-7364-00 Note Before using this information and the product it supports, read the information in “Notices” on page 511. First edition This edition applies to IBM XL C/C++ for Blue Gene/Q, V12.1 (Program 5799-AG1) and to all subsequent releases and modifications until otherwise indicated in new editions. Make sure you are using the correct edition for the level of the product. © Copyright IBM Corporation 1998, 2012. US Government Users Restricted Rights – Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. Contents About this information ........ix The register storage class specifier ......54 Who should read this information .......ix The __thread storage class specifier (IBM How to use this information .........ix extension) ..............56 How this information is organized .......ix Type specifiers .............58 Conventions ..............x Integral types.............58 Related information ...........xiii Boolean types ............59 IBM XL C/C++ information .......xiii floating-point types...........59 Standards and specifications .......xiv Character types ............60 Other IBM information .........xv The void type ............61 Other information ...........xv Vector types (IBM extension) .......61 Technical support ............xv User-defined types ...........62 How to send your comments ........xv The auto type specifier (C++0x) ......81 The decltype(expression) type specifier (C++0x) . 83 Chapter 1. Scope and linkage .....1 Compatibility of arithmetic types (C only) ....88 Type qualifiers .............89 Scope .................2 The __align type qualifier (IBM extension) . 90 Block/local scope ............2 The const type qualifier .........92 Function scope ............3 The restrict type qualifier .........93 Function prototype scope .........3 The volatile type qualifier ........94 File/global scope ............3 Type attributes (IBM extension)........95 Examples of scope in C ..........4 The aligned type attribute ........96 Class scope (C++ only) ..........5 The packed type attribute ........97 Namespaces of identifiers .........5 The transparent_union type attribute (C only) . 97 Name hiding (C++ only) .........6 Program linkage .............7 Internal linkage ............8 Chapter 4. Declarators ........99 External linkage ............8 Overview of declarators ..........99 No linkage ..............9 Examples of declarators .........101 Language linkage (C++ only) ........9 Type names ..............101 Pointers ...............102 Chapter 2. Lexical Elements .....13 Pointer arithmetic ...........103 Type-based aliasing ..........104 Tokens ................13 Compatibility of pointers (C only) .....105 Keywords ..............13 Arrays................106 Identifiers ..............15 Variable length arrays .........107 Literals ...............19 Compatibility of arrays .........108 Punctuators and operators ........32 References (C++ only) ..........109 Source program character set ........34 Initializers ..............110 Multibyte characters ..........34 Initialization and storage classes ......111 Escape sequences ...........35 Designated initializers for aggregate types (C The Unicode standard ..........36 only) ...............112 Digraph characters ...........38 Initialization of vectors (IBM extension) . 114 Trigraph sequences ...........39 Initialization of structures and unions ....115 Comments...............39 Initialization of enumerations .......117 Initialization of pointers .........118 Chapter 3. Data objects and Initialization of arrays .........119 declarations ............43 Initialization of references (C++ only) ....121 Overview of data objects and declarations ....43 Initialization of complex types (C1X) ....125 Overview of data objects .........43 Variable attributes (IBM extension) ......126 Overview of data declarations and definitions . 45 The aligned variable attribute .......127 _Static_assert declaration (C1X)........47 The common and nocommon variable attributes 128 static_assert declaration (C++0x) .......48 The init_priority variable attribute (C++ only) 129 Storage class specifiers...........50 The mode variable attribute .......129 The auto storage class specifier .......51 The packed variable attribute .......130 The static storage class specifier ......51 The section variable attribute .......130 The extern storage class specifier ......53 The tls_model attribute .........131 The mutable storage class specifier (C++ only). 54 © Copyright IBM Corp. 1998, 2012 iii The weak variable attribute........132 Pointer to member operators .* ->* (C++ only) 177 Conditional expressions ..........178 Chapter 5. Type conversions .....133 Types in conditional C expressions (C only) . 179 Arithmetic conversions and promotions ....134 Types in conditional C++ expressions (C++ Integral conversions ..........134 only) ...............179 Boolean conversions ..........135 Examples of conditional expressions.....179 floating-point conversions ........135 Cast expressions ............180 Usual arithmetic conversions .......136 Cast operator ()............180 Integral and floating-point promotions ....138 The static_cast operator (C++ only) .....183 Lvalue-to-rvalue conversions ........140 The reinterpret_cast operator (C++ only) . 185 Pointer conversions ...........141 The const_cast operator (C++ only) .....186 Conversion to void* ..........142 The dynamic_cast operator (C++ only) ....188 Reference conversions (C++ only) ......142 Compound literal expressions ........191 Function argument conversions .......143 new expressions (C++ only) ........191 Placement syntax ...........193 Chapter 6. Expressions and operators 145 Initialization of objects created with the new operator ..............194 Lvalues and rvalues ...........145 Handling new allocation failure ......194 Primary expressions ...........147 delete expressions (C++ only) ........195 Names ..............148 throw expressions (C++ only) ........196 Literals ..............148 Label value expressions (IBM extension) ....196 Integer constant expressions .......148 Operator precedence and associativity .....197 Identifier expressions (C++ only) ......149 Reference collapsing (C++0x) ........201 Parenthesized expressions ( ) .......150 Scope resolution operator :: (C++ only)....151 Function call expressions .........152 Chapter 7. Statements .......205 Member expressions ...........152 Labeled statements ...........205 Dot operator . ............153 Locally declared labels (IBM extension)....206 Arrow operator -> ..........153 Labels as values (IBM extension) ......206 Unary expressions ............153 Expression statements ..........207 Increment operator ++ .........154 Resolution of ambiguous statements (C++ only) 207 Decrement operator -- .........154 Block statements ............208 Unary plus operator + .........155 Example of blocks ...........208 Unary minus operator - .........155 Statement expressions (IBM extension) ....209 Logical negation operator ! ........155 Selection statements ...........209 Bitwise negation operator ~ .......156 The if statement ...........209 Address operator & ..........156 The switch statement ..........211 Indirection operator *..........157 Iteration statements ...........215 The typeid operator (C++ only) ......158 The while statement ..........215 The __alignof__ operator (IBM extension) . 159 The do statement ...........216 The sizeof operator ..........160 The for statement ...........217 The typeof operator (IBM extension).....162 Jump statements ............219 The __real__ and __imag__ operators ....163 The break statement ..........219 Binary expressions............164 The continue statement .........220 Assignment operators .........165 The return statement ..........221 Multiplication operator * ........167 The goto statement ..........223 Division operator / ..........167 Null statement .............224 Remainder operator % .........167 Inline assembly statements (IBM extension) . 224 Addition operator + ..........168 Supported and unsupported constructs....228 Subtraction operator - .........168 Restrictions on inline assembly statements. 229 Bitwise left and right shift operators << >> . 168 Examples of inline assembly statements . 229 Relational operators<><=>= ......169 Equality and inequality operators == != . 170 Chapter 8. Functions ........235 Bitwise AND operator & ........171 Function declarations and definitions .....235 Bitwise exclusive OR operator ^ ......172 Function declarations..........236 Bitwise inclusive OR operator | ......172 Function definitions ..........236 Logical AND operator && ........173 Examples of function declarations .....237 Logical OR operator || .........173 Examples of function definitions ......238 Array subscripting operator [ ] ......174 Compatible functions (C only).......239 Vector subscripting operator [ ] (IBM extension) 175 Multiple function declarations (C++ only) . 239 Comma operator , ...........176 Function storage class specifiers .......240 iv XL C/C++: Language Reference The static storage class specifier ......240 Overloading binary operators .......293 The extern storage class specifier ......241 Overloading assignments ........294 Function specifiers ...........242 Overloading function calls ........295 The inline function specifier .......242 Overloading subscripting ........296 The _Noreturn function specifier ......247 Overloading