C CPP Reference Manual

Embed Size (px)

Citation preview

  • 8/9/2019 C CPP Reference Manual

    1/479

    OS/390

    C/C++Language Reference

    SC09-2360-05

  • 8/9/2019 C CPP Reference Manual

    2/479

  • 8/9/2019 C CPP Reference Manual

    3/479

    OS/390

    C/C++Language Reference

    SC09-2360-05

  • 8/9/2019 C CPP Reference Manual

    4/479

    Note!

    Before using this information and the product it supports, be sure to read the information in Notices on page 411.

    Sixth Edition (September 2000)

    This edition applies to Version 2 Release 10 Modification 0 of OS/390 C/C++ (5647-A01) and to all subsequentreleases and modifications until otherwise indicated in new editions. This edition replaces SC09-2360-04. Make surethat you use the correct edition for the level of the program listed above. Also, ensure that you apply all necessaryPTFs for the program.

    Technical changes in the text since the last release of this book are indicated by a vertical line (|) to the left of thechange.

    Order publications through your IBM representative or the IBM branch office serving your location. Publications arenot stocked at the address below. Note that the OS/390 C/C++ publications are available through the OS/390 Librarypage at: http://www.ibm.com/s390/os390/bkserv/

    IBM welcomes your comments. You can send your comments in any one of the following methods:

    v Electronically to the network ID listed below. Be sure to include your entire network address if you want a reply.

    Internet: [email protected]: toribm(torrcf)

    v By FAX, use the following number:

    United States and Canada: (416) 448-6161Other countries: (+1) 416-448-6161

    v By mail, to the following address:

    IBM Canada Ltd. LaboratoryInformation Development2G/KB7/1150/TOR1150 Eglinton Avenue EastToronto, Ontario, Canada M3C 1H7

    If you send comments, include the title and order number of this book, and the page number or topic related to your

    comment. When you send information to IBM, you grant IBM a nonexclusive right to use or distribute the information

    in any way it believes appropriate without incurring any obligation to you.

    Copyright International Business Machines Corporation 1996, 2000. All rights reserved.US Government Users Restricted Rights Use, duplication or disclosure restricted by GSA ADP Schedule Contractwith IBM Corp.

  • 8/9/2019 C CPP Reference Manual

    5/479

    Contents

    Part 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

    Chapter 1. About This Book. . . . . . . . . . . . . . . . . . . . 3Who Should Use This Book . . . . . . . . . . . . . . . . . . . . 3A Note about Examples . . . . . . . . . . . . . . . . . . . . . . 3IBM OS/390 C/C++ and Related Publications . . . . . . . . . . . . . . 4

    Hardcopy Books . . . . . . . . . . . . . . . . . . . . . . . . . 8PDF Books. . . . . . . . . . . . . . . . . . . . . . . . . . . 8Softcopy Books . . . . . . . . . . . . . . . . . . . . . . . . . 9Softcopy Examples . . . . . . . . . . . . . . . . . . . . . . . . 9

    OS/390 C/C++ on the World Wide Web . . . . . . . . . . . . . . . . 10How to Read the Syntax Diagrams . . . . . . . . . . . . . . . . . 10

    Chapter 2. About IBM OS/390 C/C++ . . . . . . . . . . . . . . . . 13

    Changes for Version 2 Release 10 . . . . . . . . . . . . . . . . . 13OS/390 Language Environment Downward Compatibility . . . . . . . . 14

    The C/C++ Compilers . . . . . . . . . . . . . . . . . . . . . . 15The C Language . . . . . . . . . . . . . . . . . . . . . . . 15The C++ Language . . . . . . . . . . . . . . . . . . . . . . 15

    Common Features of the OS/390 C and C++ Compilers. . . . . . . . . 15OS/390 C Compiler Specific Features . . . . . . . . . . . . . . . 17OS/390 C++ Compiler Specific Features . . . . . . . . . . . . . . 17

    Utilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

    Class Libraries . . . . . . . . . . . . . . . . . . . . . . . . . 18Class Library Source. . . . . . . . . . . . . . . . . . . . . . 19

    The Debug Tool . . . . . . . . . . . . . . . . . . . . . . . . 19IBM C/C++ Productivity Tools for OS/390 . . . . . . . . . . . . . . . 20

    OS/390 Language Environment . . . . . . . . . . . . . . . . . . . 20The Program Management Binder . . . . . . . . . . . . . . . . . . 21

    OS/390 UNIX System Services (OS/390 UNIX) . . . . . . . . . . . . . 22OS/390 C/C++ Applications with OS/390 UNIX C/C++ Functions . . . . . . 24

    Input and Output . . . . . . . . . . . . . . . . . . . . . . . . 24I/O Interfaces . . . . . . . . . . . . . . . . . . . . . . . . 24File Types. . . . . . . . . . . . . . . . . . . . . . . . . . 25Additional I/O Features . . . . . . . . . . . . . . . . . . . . . 25

    The System Programming C Facility . . . . . . . . . . . . . . . . . 26

    Interaction with Other IBM Products . . . . . . . . . . . . . . . . . 26Additional Features of OS/390 C/C++ . . . . . . . . . . . . . . . . 27

    Part 2. The C and C++ Languages . . . . . . . . . . . . . . . . . . . . . . 31

    Chapter 3. Introduction to C and C++ . . . . . . . . . . . . . . . . 33

    Overview of the C Language . . . . . . . . . . . . . . . . . . . . 33C Source Programs . . . . . . . . . . . . . . . . . . . . . . . 34

    CBC3RAAA - example C program . . . . . . . . . . . . . . . . . 34C Source Files . . . . . . . . . . . . . . . . . . . . . . . . . 35

    CBC3RAAB - Source File 1 . . . . . . . . . . . . . . . . . . . 35

    CBC3RMAX - Source file 2 . . . . . . . . . . . . . . . . . . . 36Program Execution . . . . . . . . . . . . . . . . . . . . . . . 36Scope in C . . . . . . . . . . . . . . . . . . . . . . . . . . 37

    Block Scope . . . . . . . . . . . . . . . . . . . . . . . . . 37

    Function Scope. . . . . . . . . . . . . . . . . . . . . . . . 37

    Copyright IBM Corp. 1996, 2000 iii

    ||

    ||

  • 8/9/2019 C CPP Reference Manual

    6/479

    File Scope . . . . . . . . . . . . . . . . . . . . . . . . . 37Function Prototype Scope . . . . . . . . . . . . . . . . . . . . 37

    Example of Scope in C . . . . . . . . . . . . . . . . . . . . . 37Related Information . . . . . . . . . . . . . . . . . . . . . . 38

    Program Linkage . . . . . . . . . . . . . . . . . . . . . . . . 38Internal Linkage . . . . . . . . . . . . . . . . . . . . . . . 39

    External Linkage . . . . . . . . . . . . . . . . . . . . . . . 39

    No Linkage . . . . . . . . . . . . . . . . . . . . . . . . . 40Storage Duration . . . . . . . . . . . . . . . . . . . . . . . . 40Name Spaces . . . . . . . . . . . . . . . . . . . . . . . . . 40

    Related Information . . . . . . . . . . . . . . . . . . . . . . 41Command-Line Arguments . . . . . . . . . . . . . . . . . . . . 41

    Under OS/390 Batch . . . . . . . . . . . . . . . . . . . . . . 41Under IMS . . . . . . . . . . . . . . . . . . . . . . . . . 42

    Under CICS . . . . . . . . . . . . . . . . . . . . . . . . . 42Under TSO Command . . . . . . . . . . . . . . . . . . . . . 42Under TSO Call . . . . . . . . . . . . . . . . . . . . . . . 42Under OS/390 UNIX Shell . . . . . . . . . . . . . . . . . . . . 42

    Related Information . . . . . . . . . . . . . . . . . . . . . . 43Overview of the C++ Language . . . . . . . . . . . . . . . . . . . 43

    C++ Support for Object-Oriented Programming . . . . . . . . . . . . . 43Data Abstraction . . . . . . . . . . . . . . . . . . . . . . . 43Encapsulation . . . . . . . . . . . . . . . . . . . . . . . . 44

    Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . 44Dynamic Binding and Polymorphism . . . . . . . . . . . . . . . . 44Other Features of C++ . . . . . . . . . . . . . . . . . . . . . 45

    C++ Programs . . . . . . . . . . . . . . . . . . . . . . . . . 45

    CBC3X02D . . . . . . . . . . . . . . . . . . . . . . . . . 47Scope in C++ . . . . . . . . . . . . . . . . . . . . . . . . . 47

    Local Scope . . . . . . . . . . . . . . . . . . . . . . . . . 47Function Scope. . . . . . . . . . . . . . . . . . . . . . . . 48

    File Scope . . . . . . . . . . . . . . . . . . . . . . . . . 48Class Scope . . . . . . . . . . . . . . . . . . . . . . . . . 48

    Simple C++ Input and Output . . . . . . . . . . . . . . . . . . . 48CBC3X02F . . . . . . . . . . . . . . . . . . . . . . . . . 49

    Output (cout, cerr, and clog) . . . . . . . . . . . . . . . . . . . 49Input (cin) . . . . . . . . . . . . . . . . . . . . . . . . . . 50

    Linkage Specifications Linking to non-C++ Programs. . . . . . . . . . 50CBC3X02J . . . . . . . . . . . . . . . . . . . . . . . . . 51

    Chapter 4. Lexical Elements of C and C++ . . . . . . . . . . . . . . 53Tokens . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53Source Program Character Set . . . . . . . . . . . . . . . . . . . 53

    Trigraph Sequences . . . . . . . . . . . . . . . . . . . . . . 54

    Digraph Characters . . . . . . . . . . . . . . . . . . . . . . 55

    Additional Keywords (C++ only) . . . . . . . . . . . . . . . . . . 56Comments . . . . . . . . . . . . . . . . . . . . . . . . . . 56C++ Comments. . . . . . . . . . . . . . . . . . . . . . . . 58

    Identifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . 58Special Characters in Identifiers . . . . . . . . . . . . . . . . . 58Case Sensitivity in Identifiers . . . . . . . . . . . . . . . . . . . 59Significant Characters in Identifiers . . . . . . . . . . . . . . . . 59

    Keywords . . . . . . . . . . . . . . . . . . . . . . . . . . 59OS/390 C/C++ External Name Mapping . . . . . . . . . . . . . . . 60OS/390 Long Name Support . . . . . . . . . . . . . . . . . . . 60

    Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . 61

    iv OS/390 V2R10.0 C/C++ Language Reference

  • 8/9/2019 C CPP Reference Manual

    7/479

    Integer Constants . . . . . . . . . . . . . . . . . . . . . . . 62Floating-Point Constants . . . . . . . . . . . . . . . . . . . . 63

    Fixed-Point Decimal Constants (C Only) . . . . . . . . . . . . . . 65Character Constants . . . . . . . . . . . . . . . . . . . . . . 65String Literals . . . . . . . . . . . . . . . . . . . . . . . . 66Escape Sequences . . . . . . . . . . . . . . . . . . . . . . 68

    Chapter 5. Declarations . . . . . . . . . . . . . . . . . . . . . 71Declarations Overview . . . . . . . . . . . . . . . . . . . . . . 71Block Scope Data Declarations . . . . . . . . . . . . . . . . . . . 72

    Initialization . . . . . . . . . . . . . . . . . . . . . . . . . 73Storage . . . . . . . . . . . . . . . . . . . . . . . . . . 73Related Information . . . . . . . . . . . . . . . . . . . . . . 73

    File Scope Data Declarations . . . . . . . . . . . . . . . . . . . 73

    Initialization . . . . . . . . . . . . . . . . . . . . . . . . . 74Storage . . . . . . . . . . . . . . . . . . . . . . . . . . 74Related Information . . . . . . . . . . . . . . . . . . . . . . 74

    Objects. . . . . . . . . . . . . . . . . . . . . . . . . . . . 74

    Storage Class Specifiers . . . . . . . . . . . . . . . . . . . . . 74auto Storage Class Specifier . . . . . . . . . . . . . . . . . . . 75

    extern Storage Class Specifier . . . . . . . . . . . . . . . . . . 77register Storage Class Specifier. . . . . . . . . . . . . . . . . . 83static Storage Class Specifier . . . . . . . . . . . . . . . . . . 83

    typedef . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85Examples of typedef Declarations . . . . . . . . . . . . . . . . . 86Related Information . . . . . . . . . . . . . . . . . . . . . . 86

    Type Specifiers . . . . . . . . . . . . . . . . . . . . . . . . . 87

    Characters . . . . . . . . . . . . . . . . . . . . . . . . . 87Floating-Point Variables. . . . . . . . . . . . . . . . . . . . . 88Fixed-Point Decimal Data Types (C Only) . . . . . . . . . . . . . . 89Integer Variables . . . . . . . . . . . . . . . . . . . . . . . 90

    Enumerations . . . . . . . . . . . . . . . . . . . . . . . . 91Pointers . . . . . . . . . . . . . . . . . . . . . . . . . . 95void Type . . . . . . . . . . . . . . . . . . . . . . . . . 100Arrays. . . . . . . . . . . . . . . . . . . . . . . . . . . 101

    Structures . . . . . . . . . . . . . . . . . . . . . . . . . 107Unions . . . . . . . . . . . . . . . . . . . . . . . . . . 114Declarators . . . . . . . . . . . . . . . . . . . . . . . . . 121Initializers . . . . . . . . . . . . . . . . . . . . . . . . . 129C/C++ Data Mapping . . . . . . . . . . . . . . . . . . . . . 131

    C++ Function Specifiers . . . . . . . . . . . . . . . . . . . . 131C++ References . . . . . . . . . . . . . . . . . . . . . . . 131

    Chapter 6. Expressions and Operators . . . . . . . . . . . . . . . 133

    Operator Precedence and Associativity . . . . . . . . . . . . . . . 133

    Examples of Expressions and Precedence . . . . . . . . . . . . . 135Operands . . . . . . . . . . . . . . . . . . . . . . . . . . 135lvalues . . . . . . . . . . . . . . . . . . . . . . . . . . . 136

    Examples of lvalues . . . . . . . . . . . . . . . . . . . . . 136Type-based Aliasing . . . . . . . . . . . . . . . . . . . . . 136Related Information . . . . . . . . . . . . . . . . . . . . . . 137

    Primary Expressions . . . . . . . . . . . . . . . . . . . . . . 137

    C++ Scope Resolution Operator (::) . . . . . . . . . . . . . . . . 138Parenthesized Expressions ( ) . . . . . . . . . . . . . . . . . 138Constant Expressions . . . . . . . . . . . . . . . . . . . . . 139Function Calls ( ) . . . . . . . . . . . . . . . . . . . . . . 140

    Contents v

  • 8/9/2019 C CPP Reference Manual

    8/479

    Array Subscript [ ] (Array Element Specification) . . . . . . . . . . . 141Dot Operator (.) . . . . . . . . . . . . . . . . . . . . . . . 142

    Arrow Operator (>) . . . . . . . . . . . . . . . . . . . . . 142Unary Expressions . . . . . . . . . . . . . . . . . . . . . . . 142

    Increment (++) . . . . . . . . . . . . . . . . . . . . . . . 143Decrement () . . . . . . . . . . . . . . . . . . . . . . . 143

    Unary Plus (+) . . . . . . . . . . . . . . . . . . . . . . . 144

    Unary Minus () . . . . . . . . . . . . . . . . . . . . . . . 144Logical Negation (!) . . . . . . . . . . . . . . . . . . . . . . 144Bitwise Negation (). . . . . . . . . . . . . . . . . . . . . . 144

    Address (&) . . . . . . . . . . . . . . . . . . . . . . . . 145Indirection (*) . . . . . . . . . . . . . . . . . . . . . . . . 145Cast Expressions . . . . . . . . . . . . . . . . . . . . . . 146sizeof (Size of an Object) . . . . . . . . . . . . . . . . . . . 146

    digitsof and precisionof (C Only) . . . . . . . . . . . . . . . . . 148C++ new Operator . . . . . . . . . . . . . . . . . . . . . . 148C++ delete Operator . . . . . . . . . . . . . . . . . . . . . 151C++ throw Expressions . . . . . . . . . . . . . . . . . . . . 152

    Binary Expressions . . . . . . . . . . . . . . . . . . . . . . . 152Multiplication (*) . . . . . . . . . . . . . . . . . . . . . . . 153

    Division (/) . . . . . . . . . . . . . . . . . . . . . . . . . 153Remainder (%) . . . . . . . . . . . . . . . . . . . . . . . 153Addition (+) . . . . . . . . . . . . . . . . . . . . . . . . . 154

    Subtraction () . . . . . . . . . . . . . . . . . . . . . . . 154Bitwise Left and Right Shift (>) . . . . . . . . . . . . . . . . 154Relational (< > =) . . . . . . . . . . . . . . . . . . . . . 155Equality (== !=) . . . . . . . . . . . . . . . . . . . . . . . 156

    Bitwise AND (&) . . . . . . . . . . . . . . . . . . . . . . . 157Bitwise Exclusive OR (|) . . . . . . . . . . . . . . . . . . . . 158Bitwise Inclusive OR (|) . . . . . . . . . . . . . . . . . . . . 158Logical AND (&&) . . . . . . . . . . . . . . . . . . . . . . 159

    Logical OR (||) . . . . . . . . . . . . . . . . . . . . . . . 160C++ Pointer-to-Member Operators (.* >*) . . . . . . . . . . . . . 160

    Conditional Expressions . . . . . . . . . . . . . . . . . . . . . 161Type of Conditional C Expressions . . . . . . . . . . . . . . . . 162

    Type of Conditional C++ Expressions . . . . . . . . . . . . . . . 162Examples of Conditional Expressions . . . . . . . . . . . . . . . 162

    Assignment Expressions . . . . . . . . . . . . . . . . . . . . . 163Simple Assignment (=) . . . . . . . . . . . . . . . . . . . . 163Compound Assignment . . . . . . . . . . . . . . . . . . . . 164

    Comma Expression (,). . . . . . . . . . . . . . . . . . . . . . 165

    Chapter 7. Implicit Type Conversions . . . . . . . . . . . . . . . 167Integral Promotions . . . . . . . . . . . . . . . . . . . . . . . 167

    Standard Type Conversions. . . . . . . . . . . . . . . . . . . . 167

    Signed-Integer Conversions. . . . . . . . . . . . . . . . . . . 168Unsigned-Integer Conversions . . . . . . . . . . . . . . . . . . 168Floating-Point Conversions . . . . . . . . . . . . . . . . . . . 168

    Pointer Conversions . . . . . . . . . . . . . . . . . . . . . 168Reference Conversions . . . . . . . . . . . . . . . . . . . . 169Pointer-to-Member Conversions . . . . . . . . . . . . . . . . . 169Function Argument Conversions . . . . . . . . . . . . . . . . . 169

    Other Conversions . . . . . . . . . . . . . . . . . . . . . . 170Arithmetic Conversions . . . . . . . . . . . . . . . . . . . . . 170

    Chapter 8. Functions . . . . . . . . . . . . . . . . . . . . . . 173

    vi OS/390 V2R10.0 C/C++ Language Reference

  • 8/9/2019 C CPP Reference Manual

    9/479

    Functions Overview. . . . . . . . . . . . . . . . . . . . . . . 173C++ Enhancements to C Functions . . . . . . . . . . . . . . . . . 173Function Declarations . . . . . . . . . . . . . . . . . . . . . . 174

    C Function Declarations . . . . . . . . . . . . . . . . . . . . 174C++ Function Declarations . . . . . . . . . . . . . . . . . . . 174Examples of Function Declarations . . . . . . . . . . . . . . . . 176Function Definitions. . . . . . . . . . . . . . . . . . . . . . 178

    Related Information . . . . . . . . . . . . . . . . . . . . . . 183The main() Function . . . . . . . . . . . . . . . . . . . . . . 183

    Arguments to main . . . . . . . . . . . . . . . . . . . . . . 183Example of Arguments to main . . . . . . . . . . . . . . . . . 184

    Calling Functions and Passing Arguments . . . . . . . . . . . . . . 184Passing Arguments in C++ . . . . . . . . . . . . . . . . . . . 186Examples of Calling Functions . . . . . . . . . . . . . . . . . . 186Passing Arguments by Reference . . . . . . . . . . . . . . . . 188

    Default Arguments in C++ Functions . . . . . . . . . . . . . . . . 189CBC3X06B . . . . . . . . . . . . . . . . . . . . . . . . . 189Restrictions on Default Arguments . . . . . . . . . . . . . . . . 190Evaluating Default Arguments . . . . . . . . . . . . . . . . . . 190

    Function Return Values . . . . . . . . . . . . . . . . . . . . . 191

    Using References as Return Types . . . . . . . . . . . . . . . . 192Pointers to Functions . . . . . . . . . . . . . . . . . . . . . . 192C++ Inline Functions . . . . . . . . . . . . . . . . . . . . . . 194

    Chapter 9. Statements . . . . . . . . . . . . . . . . . . . . . 195Labels . . . . . . . . . . . . . . . . . . . . . . . . . . . 195

    Examples . . . . . . . . . . . . . . . . . . . . . . . . . 195Related Information . . . . . . . . . . . . . . . . . . . . . . 195

    Block . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196Initialization within Block Statements . . . . . . . . . . . . . . . 196Example . . . . . . . . . . . . . . . . . . . . . . . . . . 197Related Information . . . . . . . . . . . . . . . . . . . . . . 197

    break . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197Restrictions. . . . . . . . . . . . . . . . . . . . . . . . . 198Examples . . . . . . . . . . . . . . . . . . . . . . . . . 198Related Information . . . . . . . . . . . . . . . . . . . . . . 199

    continue . . . . . . . . . . . . . . . . . . . . . . . . . . . 199Restrictions. . . . . . . . . . . . . . . . . . . . . . . . . 199Examples . . . . . . . . . . . . . . . . . . . . . . . . . 200Related Information . . . . . . . . . . . . . . . . . . . . . . 201

    do . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201Example . . . . . . . . . . . . . . . . . . . . . . . . . . 201Related Information . . . . . . . . . . . . . . . . . . . . . . 202

    Expression . . . . . . . . . . . . . . . . . . . . . . . . . . 202Examples . . . . . . . . . . . . . . . . . . . . . . . . . 202

    Resolving Ambiguous Statements in C++ . . . . . . . . . . . . . . 202for . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203Examples . . . . . . . . . . . . . . . . . . . . . . . . . 204Related Information . . . . . . . . . . . . . . . . . . . . . . 205

    goto . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206Example . . . . . . . . . . . . . . . . . . . . . . . . . . 206

    if . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207Examples . . . . . . . . . . . . . . . . . . . . . . . . . 207

    null . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208Example . . . . . . . . . . . . . . . . . . . . . . . . . . 208

    return . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208

    Contents vii

  • 8/9/2019 C CPP Reference Manual

    10/479

    Value of a return Expression and Function Value . . . . . . . . . . . 209Examples . . . . . . . . . . . . . . . . . . . . . . . . . 209Related Information . . . . . . . . . . . . . . . . . . . . . . 210

    switch . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210Restrictions . . . . . . . . . . . . . . . . . . . . . . . . . 211Examples . . . . . . . . . . . . . . . . . . . . . . . . . 212Related Information . . . . . . . . . . . . . . . . . . . . . . 214

    while . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214Example . . . . . . . . . . . . . . . . . . . . . . . . . . 214Related Information . . . . . . . . . . . . . . . . . . . . . . 214

    Chapter 10. Preprocessor Directives . . . . . . . . . . . . . . . 215Preprocessor Overview . . . . . . . . . . . . . . . . . . . . . 215Preprocessor Directive Format. . . . . . . . . . . . . . . . . . . 216Phases of Preprocessing. . . . . . . . . . . . . . . . . . . . . 216Macro Definition and Expansion (#define) . . . . . . . . . . . . . . 217

    Object-Like Macros . . . . . . . . . . . . . . . . . . . . . . 217Function-Like Macros . . . . . . . . . . . . . . . . . . . . . 218

    Scope of Macro Names (#undef) . . . . . . . . . . . . . . . . . . 221Examples of #undef Directives. . . . . . . . . . . . . . . . . . 221

    Single Number Sign Operator (#) . . . . . . . . . . . . . . . . . . 221Examples of the # Operator. . . . . . . . . . . . . . . . . . . 222Related Information . . . . . . . . . . . . . . . . . . . . . . 222

    Macro Concatenation with the ## Operator . . . . . . . . . . . . . . 222Double Number Sign Operator (##) . . . . . . . . . . . . . . . . 223

    Preprocessor Error Directive (#error) . . . . . . . . . . . . . . . . 223Related Information . . . . . . . . . . . . . . . . . . . . . . 224

    File Inclusion (#include) . . . . . . . . . . . . . . . . . . . . . 224Predefined Macro Names . . . . . . . . . . . . . . . . . . . . 225

    ANSI/ISO Standard Predefined Macro Names . . . . . . . . . . . . 225OS/390 C/C++ Predefined Macro Names . . . . . . . . . . . . . . 226Examples of Predefined Macros . . . . . . . . . . . . . . . . . 232

    Conditional Compilation Directives . . . . . . . . . . . . . . . . . 233#if, #elif . . . . . . . . . . . . . . . . . . . . . . . . . . 234#ifdef . . . . . . . . . . . . . . . . . . . . . . . . . . . 235#ifndef . . . . . . . . . . . . . . . . . . . . . . . . . . 235#else . . . . . . . . . . . . . . . . . . . . . . . . . . . 236#endif . . . . . . . . . . . . . . . . . . . . . . . . . . . 236Examples of Conditional Compilation Directives . . . . . . . . . . . 236

    Line Control (#line) . . . . . . . . . . . . . . . . . . . . . . . 237Example of #line Directives . . . . . . . . . . . . . . . . . . . 238

    Null Directive (#) . . . . . . . . . . . . . . . . . . . . . . . . 238Pragma Directives (#pragma) . . . . . . . . . . . . . . . . . . . 238

    Restrictions on #pragma Directives . . . . . . . . . . . . . . . . 241IPA Considerations . . . . . . . . . . . . . . . . . . . . . . 242

    chars . . . . . . . . . . . . . . . . . . . . . . . . . . . 243checkout. . . . . . . . . . . . . . . . . . . . . . . . . . 243comment . . . . . . . . . . . . . . . . . . . . . . . . . 244convlit. . . . . . . . . . . . . . . . . . . . . . . . . . . 245csect . . . . . . . . . . . . . . . . . . . . . . . . . . . 246define (C++ Only) . . . . . . . . . . . . . . . . . . . . . . 247disjoint (C Only) . . . . . . . . . . . . . . . . . . . . . . . 247environment (C Only) . . . . . . . . . . . . . . . . . . . . . 248export . . . . . . . . . . . . . . . . . . . . . . . . . . . 248filetag . . . . . . . . . . . . . . . . . . . . . . . . . . . 249hdrstop . . . . . . . . . . . . . . . . . . . . . . . . . . 249

    viii OS/390 V2R10.0 C/C++ Language Reference

  • 8/9/2019 C CPP Reference Manual

    11/479

    implementation (C++ Only) . . . . . . . . . . . . . . . . . . . 250info (C++ Only) . . . . . . . . . . . . . . . . . . . . . . . 250inline (C Only) - also see noinline . . . . . . . . . . . . . . . . 251isolated_call . . . . . . . . . . . . . . . . . . . . . . . . 253langlvl. . . . . . . . . . . . . . . . . . . . . . . . . . . 254leaves. . . . . . . . . . . . . . . . . . . . . . . . . . . 256linkage . . . . . . . . . . . . . . . . . . . . . . . . . . 256

    longname . . . . . . . . . . . . . . . . . . . . . . . . . 258map . . . . . . . . . . . . . . . . . . . . . . . . . . . 259margins . . . . . . . . . . . . . . . . . . . . . . . . . . 261noinline (C and C++) - also see inline . . . . . . . . . . . . . . . 262options (C Only) . . . . . . . . . . . . . . . . . . . . . . . 263option_override . . . . . . . . . . . . . . . . . . . . . . . 264pack . . . . . . . . . . . . . . . . . . . . . . . . . . . 266page (C Only) . . . . . . . . . . . . . . . . . . . . . . . . 267pagesize (C Only) . . . . . . . . . . . . . . . . . . . . . . 267priority (C++ Only) . . . . . . . . . . . . . . . . . . . . . . 267reachable . . . . . . . . . . . . . . . . . . . . . . . . . 268runopts . . . . . . . . . . . . . . . . . . . . . . . . . . 268sequence . . . . . . . . . . . . . . . . . . . . . . . . . 270

    skip (C Only) . . . . . . . . . . . . . . . . . . . . . . . . 271strings . . . . . . . . . . . . . . . . . . . . . . . . . . 271subtitle (C Only) . . . . . . . . . . . . . . . . . . . . . . . 271target (C Only) . . . . . . . . . . . . . . . . . . . . . . . 272title (C Only) . . . . . . . . . . . . . . . . . . . . . . . . 273variable . . . . . . . . . . . . . . . . . . . . . . . . . . 273wsizeof . . . . . . . . . . . . . . . . . . . . . . . . . . 273

    Part 3. C++ Language Elements . . . . . . . . . . . . . . . . . . . . . . . 275

    Chapter 11. C++ Classes . . . . . . . . . . . . . . . . . . . . 277C++ Classes Overview . . . . . . . . . . . . . . . . . . . . . 277

    Classes and Structures . . . . . . . . . . . . . . . . . . . . 277Aggregate Classes . . . . . . . . . . . . . . . . . . . . . . 278

    Declaring Class Objects . . . . . . . . . . . . . . . . . . . . . 278Class Names . . . . . . . . . . . . . . . . . . . . . . . . 279Using Class Objects . . . . . . . . . . . . . . . . . . . . . 280

    Scope of Class Names . . . . . . . . . . . . . . . . . . . . . 282CBC3X10E . . . . . . . . . . . . . . . . . . . . . . . . . 282Incomplete Class Declarations . . . . . . . . . . . . . . . . . . 282Nested Classes . . . . . . . . . . . . . . . . . . . . . . . 283Local Classes . . . . . . . . . . . . . . . . . . . . . . . . 284Local Type Names . . . . . . . . . . . . . . . . . . . . . . 285

    Chapter 12. C++ Class Members and Friends . . . . . . . . . . . . 287

    Class Member Lists. . . . . . . . . . . . . . . . . . . . . . . 287Data Members . . . . . . . . . . . . . . . . . . . . . . . . 288Class-Type Class Members . . . . . . . . . . . . . . . . . . . . 288Member Functions . . . . . . . . . . . . . . . . . . . . . . . 289

    const and volatile Member Functions . . . . . . . . . . . . . . . 289Virtual Member Functions . . . . . . . . . . . . . . . . . . . 289Special Member Functions . . . . . . . . . . . . . . . . . . . 290Inline Member Functions . . . . . . . . . . . . . . . . . . . . 290Member Function Templates . . . . . . . . . . . . . . . . . . 290

    Member Scope . . . . . . . . . . . . . . . . . . . . . . . . 291CBC3X11A . . . . . . . . . . . . . . . . . . . . . . . . . 291

    Contents ix

  • 8/9/2019 C CPP Reference Manual

    12/479

    Pointers to Members . . . . . . . . . . . . . . . . . . . . . . 292CBC3X11B . . . . . . . . . . . . . . . . . . . . . . . . . 293

    The this Pointer . . . . . . . . . . . . . . . . . . . . . . . . 293CBC3X11C . . . . . . . . . . . . . . . . . . . . . . . . . 294CBC3X11D . . . . . . . . . . . . . . . . . . . . . . . . . 294

    Static Members . . . . . . . . . . . . . . . . . . . . . . . . 295Using the Class Access Operators with Static Members . . . . . . . . 296

    Static Data Members . . . . . . . . . . . . . . . . . . . . . 297Static Member Functions . . . . . . . . . . . . . . . . . . . . 299

    Member Access . . . . . . . . . . . . . . . . . . . . . . . . 299Classes and Access Control . . . . . . . . . . . . . . . . . . 300Access Specifiers . . . . . . . . . . . . . . . . . . . . . . 300

    Friends . . . . . . . . . . . . . . . . . . . . . . . . . . . 301CBC3X11I . . . . . . . . . . . . . . . . . . . . . . . . . 302CBC3X11J . . . . . . . . . . . . . . . . . . . . . . . . . 302Friend Scope . . . . . . . . . . . . . . . . . . . . . . . . 303Friend Access . . . . . . . . . . . . . . . . . . . . . . . . 304

    Chapter 13. C++ Overloading . . . . . . . . . . . . . . . . . . 305Overloading Functions. . . . . . . . . . . . . . . . . . . . . . 305

    CBC3X12A . . . . . . . . . . . . . . . . . . . . . . . . . 305Declaration Matching . . . . . . . . . . . . . . . . . . . . . 305Restrictions on Overloaded Functions . . . . . . . . . . . . . . . 306

    Argument Matching in Overloaded Functions . . . . . . . . . . . . . 306Sequence of Argument Conversions . . . . . . . . . . . . . . . 307Trivial Conversions . . . . . . . . . . . . . . . . . . . . . . 308

    Overloading Operators . . . . . . . . . . . . . . . . . . . . . 308CBC3X12B . . . . . . . . . . . . . . . . . . . . . . . . . 309General Rules for Overloading Operators. . . . . . . . . . . . . . 309Operands of Overloaded Operators . . . . . . . . . . . . . . . . 310Restrictions on Overloaded Operators . . . . . . . . . . . . . . . 311

    Overloading Unary Operators . . . . . . . . . . . . . . . . . . . 311Overloading Binary Operators . . . . . . . . . . . . . . . . . . . 311Special Overloaded Operators . . . . . . . . . . . . . . . . . . . 312

    Overloaded Assignment . . . . . . . . . . . . . . . . . . . . 312Overloaded Function Calls . . . . . . . . . . . . . . . . . . . 313Overloaded Subscripting . . . . . . . . . . . . . . . . . . . . 313Overloaded Class Member Access . . . . . . . . . . . . . . . . 314Overloaded Increment and Decrement . . . . . . . . . . . . . . . 314Overloaded new and delete . . . . . . . . . . . . . . . . . . . 316

    Chapter 14. Special C++ Member Functions . . . . . . . . . . . . . 317Constructors and Destructors Overview . . . . . . . . . . . . . . . 317Constructors . . . . . . . . . . . . . . . . . . . . . . . . . 318

    Default Constructors . . . . . . . . . . . . . . . . . . . . . 318

    Copy Constructors . . . . . . . . . . . . . . . . . . . . . . 318Construction Order of Class Objects . . . . . . . . . . . . . . . 319Explicitly Constructing Objects . . . . . . . . . . . . . . . . . . 320

    Destructors . . . . . . . . . . . . . . . . . . . . . . . . . . 320Free Store . . . . . . . . . . . . . . . . . . . . . . . . . . 322Temporary Objects . . . . . . . . . . . . . . . . . . . . . . . 324

    Related Information . . . . . . . . . . . . . . . . . . . . . . 325User-Defined Conversions . . . . . . . . . . . . . . . . . . . . 325

    Conversion by Constructor . . . . . . . . . . . . . . . . . . . 326Conversion Functions . . . . . . . . . . . . . . . . . . . . . 326

    Initialization by Constructor . . . . . . . . . . . . . . . . . . . . 327

    x OS/390 V2R10.0 C/C++ Language Reference

  • 8/9/2019 C CPP Reference Manual

    13/479

    Explicit Initialization . . . . . . . . . . . . . . . . . . . . . . 327Initializing Base Classes and Members . . . . . . . . . . . . . . 329Construction Order of Derived Class Objects . . . . . . . . . . . . 330

    Copying Class Objects . . . . . . . . . . . . . . . . . . . . . 331Copy Restrictions . . . . . . . . . . . . . . . . . . . . . . 331Copy by Assignment . . . . . . . . . . . . . . . . . . . . . 331Copy by Initialization . . . . . . . . . . . . . . . . . . . . . 332

    Chapter 15. C++ Inheritance . . . . . . . . . . . . . . . . . . . 335Inheritance Overview . . . . . . . . . . . . . . . . . . . . . . 335

    Multiple Inheritance . . . . . . . . . . . . . . . . . . . . . . 336The Inheritance Design Process . . . . . . . . . . . . . . . . . 337Direct and Indirect Base Classes . . . . . . . . . . . . . . . . . 337Polymorphism . . . . . . . . . . . . . . . . . . . . . . . . 338

    Derivation . . . . . . . . . . . . . . . . . . . . . . . . . . 338CBC3X14A . . . . . . . . . . . . . . . . . . . . . . . . . 339CBC3X14B . . . . . . . . . . . . . . . . . . . . . . . . . 339CBC3X14C . . . . . . . . . . . . . . . . . . . . . . . . . 340Syntax of a Derived Class Declaration . . . . . . . . . . . . . . . 340

    Inherited Member Access . . . . . . . . . . . . . . . . . . . . 341

    Protected Members . . . . . . . . . . . . . . . . . . . . . . 342Derivation Access of Base Classes . . . . . . . . . . . . . . . . 342Access Declarations . . . . . . . . . . . . . . . . . . . . . 343Access Resolution . . . . . . . . . . . . . . . . . . . . . . 345Access Summary . . . . . . . . . . . . . . . . . . . . . . 347

    Multiple Inheritance . . . . . . . . . . . . . . . . . . . . . . . 347Virtual Base Classes . . . . . . . . . . . . . . . . . . . . . 348Multiple Access . . . . . . . . . . . . . . . . . . . . . . . 349Accessible Base Classes. . . . . . . . . . . . . . . . . . . . 350Ambiguous Base Classes . . . . . . . . . . . . . . . . . . . 350

    Virtual Functions . . . . . . . . . . . . . . . . . . . . . . . . 351Ambiguous Virtual Function Calls. . . . . . . . . . . . . . . . . 353Virtual Function Access . . . . . . . . . . . . . . . . . . . . 354

    Abstract Classes . . . . . . . . . . . . . . . . . . . . . . . . 355

    Chapter 16. C++ Templates . . . . . . . . . . . . . . . . . . . 357Templates Overview . . . . . . . . . . . . . . . . . . . . . . 357

    CBC3X15A . . . . . . . . . . . . . . . . . . . . . . . . . 358Structuring Your Program Using Templates . . . . . . . . . . . . . . 359

    File stack.h . . . . . . . . . . . . . . . . . . . . . . . . . 359File stackdef.h . . . . . . . . . . . . . . . . . . . . . . . 359

    Class Templates . . . . . . . . . . . . . . . . . . . . . . . . 360Class Template Declarations and Definitions . . . . . . . . . . . . 362Reference and Uniqueness . . . . . . . . . . . . . . . . . . . 362Nontype Template Arguments . . . . . . . . . . . . . . . . . . 363

    Explicitly Defined Template Classes . . . . . . . . . . . . . . . . 364Function Templates . . . . . . . . . . . . . . . . . . . . . . . 365Example of a Function Template . . . . . . . . . . . . . . . . . 365Overloading Resolution for Template Functions . . . . . . . . . . . 365Defining Template Functions . . . . . . . . . . . . . . . . . . 366Explicitly Defined Template Functions . . . . . . . . . . . . . . . 366Function Template Declarations and Definitions . . . . . . . . . . . 367

    Differences between Class and Function Templates . . . . . . . . . . . 368CBC3X15B . . . . . . . . . . . . . . . . . . . . . . . . . 368

    Member Function Templates . . . . . . . . . . . . . . . . . . . 369Friends and Templates . . . . . . . . . . . . . . . . . . . . . 370

    Contents xi

  • 8/9/2019 C CPP Reference Manual

    14/479

    Static Data Members and Templates . . . . . . . . . . . . . . . . 371

    Chapter 17. C++ Exception Handling . . . . . . . . . . . . . . . 373C++ Exception Handling Overview . . . . . . . . . . . . . . . . . 373Formal and Informal Exception Handling . . . . . . . . . . . . . . . 374Using Exception Handling . . . . . . . . . . . . . . . . . . . . 374Transferring Control . . . . . . . . . . . . . . . . . . . . . . 376

    CBC3X16A . . . . . . . . . . . . . . . . . . . . . . . . . 376CBC3X16F . . . . . . . . . . . . . . . . . . . . . . . . . 377Catching Exceptions . . . . . . . . . . . . . . . . . . . . . 378Matching Exceptions Thrown and Exceptions Caught . . . . . . . . . 379Order of Catching . . . . . . . . . . . . . . . . . . . . . . 379Nested Try Blocks . . . . . . . . . . . . . . . . . . . . . . 379Rethrowing an Exception. . . . . . . . . . . . . . . . . . . . 380Using a Conditional Expression in a Throw Expression. . . . . . . . . 381

    Constructors and Destructors in Exception Handling. . . . . . . . . . . 382CBC3X16D . . . . . . . . . . . . . . . . . . . . . . . . . 383

    Exception Specifications . . . . . . . . . . . . . . . . . . . . . 384Exception Specification Syntax . . . . . . . . . . . . . . . . . 384Empty Exception Specifications . . . . . . . . . . . . . . . . . 385

    Functions without an Exception Specification . . . . . . . . . . . . 385Other Exception Specifications . . . . . . . . . . . . . . . . . 385

    Special Exception Handling Functions . . . . . . . . . . . . . . . . 386unexpected() . . . . . . . . . . . . . . . . . . . . . . . . 386terminate() . . . . . . . . . . . . . . . . . . . . . . . . . 386set_unexpected() and set_terminate() . . . . . . . . . . . . . . . 386Example of Using the Exception Handling Functions . . . . . . . . . 387

    Part 4. Appendixes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 389

    Appendix A. C and C++ Compatibility . . . . . . . . . . . . . . . 391C++ Constructs Not Found in ANSI/ISO C . . . . . . . . . . . . . . 391

    Constructs Found in Both C++ and ANSI/ISO C . . . . . . . . . . . . 391Character Array Initialization . . . . . . . . . . . . . . . . . . 391Character Constants . . . . . . . . . . . . . . . . . . . . . 392Class and typedef Names . . . . . . . . . . . . . . . . . . . 392Class and Scope Declarations . . . . . . . . . . . . . . . . . . 392const Object Initialization . . . . . . . . . . . . . . . . . . . . 392Definitions . . . . . . . . . . . . . . . . . . . . . . . . . 392Definitions within Return or Argument Types . . . . . . . . . . . . 393Enumerator Type . . . . . . . . . . . . . . . . . . . . . . 393Enumeration Type . . . . . . . . . . . . . . . . . . . . . . 393Function Declarations . . . . . . . . . . . . . . . . . . . . . 393Functions with an Empty Argument List . . . . . . . . . . . . . . 393Global Constant Linkage . . . . . . . . . . . . . . . . . . . . 393

    Jump Statements . . . . . . . . . . . . . . . . . . . . . . 393Keywords . . . . . . . . . . . . . . . . . . . . . . . . . 394main() Recursion. . . . . . . . . . . . . . . . . . . . . . . 394Names of Nested Classes . . . . . . . . . . . . . . . . . . . 394Pointers to void . . . . . . . . . . . . . . . . . . . . . . . 394Prototype Declarations . . . . . . . . . . . . . . . . . . . . 394Return without Declared Value. . . . . . . . . . . . . . . . . . 394__STDC__ Macro . . . . . . . . . . . . . . . . . . . . . . 394typedefs in Class Declarations . . . . . . . . . . . . . . . . . . 395

    Interactions with Other Products . . . . . . . . . . . . . . . . . . 395

    xii OS/390 V2R10.0 C/C++ Language Reference

  • 8/9/2019 C CPP Reference Manual

    15/479

    Appendix B. Common Usage C Language Level . . . . . . . . . . . 397

    Appendix C. Conforming to POSIX 1003.1 . . . . . . . . . . . . . 399

    Appendix D. Supporting ANSI/ISO Standards . . . . . . . . . . . . 401Implementation-Defined Behavior. . . . . . . . . . . . . . . . . . 401

    Identifiers . . . . . . . . . . . . . . . . . . . . . . . . . 401

    Characters . . . . . . . . . . . . . . . . . . . . . . . . . 402String Conversion . . . . . . . . . . . . . . . . . . . . . . 402Integers . . . . . . . . . . . . . . . . . . . . . . . . . . 403Floating-Point . . . . . . . . . . . . . . . . . . . . . . . . 403Arrays and Pointers. . . . . . . . . . . . . . . . . . . . . . 404Registers . . . . . . . . . . . . . . . . . . . . . . . . . 404Structures, Unions, Enumerations, Bit Fields . . . . . . . . . . . . 404Declarators . . . . . . . . . . . . . . . . . . . . . . . . . 405Statements . . . . . . . . . . . . . . . . . . . . . . . . . 405Preprocessing Directives . . . . . . . . . . . . . . . . . . . . 405Library Functions . . . . . . . . . . . . . . . . . . . . . . 405Error Handling. . . . . . . . . . . . . . . . . . . . . . . . 406Signals . . . . . . . . . . . . . . . . . . . . . . . . . . 407

    Translation Limits . . . . . . . . . . . . . . . . . . . . . . 407Streams, Records, and Files . . . . . . . . . . . . . . . . . . 408Memory Management . . . . . . . . . . . . . . . . . . . . . 409Environment . . . . . . . . . . . . . . . . . . . . . . . . 409Localization. . . . . . . . . . . . . . . . . . . . . . . . . 410Time . . . . . . . . . . . . . . . . . . . . . . . . . . . 410

    Notices . . . . . . . . . . . . . . . . . . . . . . . . . . . 411Programming Interface Information . . . . . . . . . . . . . . . . . 412Trademarks. . . . . . . . . . . . . . . . . . . . . . . . . . 412Standards . . . . . . . . . . . . . . . . . . . . . . . . . . 413

    Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . 415

    Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . 443OS/390 . . . . . . . . . . . . . . . . . . . . . . . . . . . 443OS/390 C/C++ . . . . . . . . . . . . . . . . . . . . . . . . 443OS/390 Language Environment . . . . . . . . . . . . . . . . . . 443Assembler . . . . . . . . . . . . . . . . . . . . . . . . . . 443COBOL . . . . . . . . . . . . . . . . . . . . . . . . . . . 444PL/I . . . . . . . . . . . . . . . . . . . . . . . . . . . . 444VS FORTRAN. . . . . . . . . . . . . . . . . . . . . . . . . 444CICS . . . . . . . . . . . . . . . . . . . . . . . . . . . . 444DB2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 444IMS/ESA. . . . . . . . . . . . . . . . . . . . . . . . . . . 445

    QMF . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445DFSMS . . . . . . . . . . . . . . . . . . . . . . . . . . . 445

    INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . 447

    Contents xiii

    ||

    ||

    ||

    ||

  • 8/9/2019 C CPP Reference Manual

    16/479

    xiv OS/390 V2R10.0 C/C++ Language Reference

  • 8/9/2019 C CPP Reference Manual

    17/479

    Part 1. Introduction

    This part describes how to use the OS/390 C/C++ Language Reference, and howto find additional information in the OS/390 C/C++ library. This part introduces theIBM OS/390 C/C++ product.

    Chapter 1. About This BookDescribes how to use this book in relation to the OS/390 C/C++ informationlibrary and related OS/390 documentation.

    Chapter 2. About IBM OS/390 C/C++

    Introduces the OS/390 C/C++ product and its key features, related OS/390environments such as OS/390 UNIX System Services, and other OS/390tools that are useful when using OS/390 C/C++.

    Copyright IBM Corp. 1996, 2000 1

  • 8/9/2019 C CPP Reference Manual

    18/479

    2 OS/390 V2R10.0 C/C++ Language Reference

  • 8/9/2019 C CPP Reference Manual

    19/479

    Chapter 1. About This Book

    This book describes the IBM C language and C++ language definitions whichcomply with the POSIX and XPG4 standards, and which the OS/390 LanguageEnvironment implements. Use this book if you are a programmer who needs tounderstand the support that IBM OS/390 C/C++ provides.

    Who Should Use This Book

    This book is intended for programmers who will write C or C++ applications underthe OS/390 operating system. This book is a reference rather than a tutorial. Itassumes that you have some experience with writing C or C++ programs and arefamiliar with the OS/390 operating system.

    A Note about Examples

    Examples that illustrate the use of the OS/390 C/C++ compiler use a simple style.They are instructional examples, and do not attempt to minimize run time, conserve

    storage, or check for errors. The examples do not demonstrate all the uses of Cand C++ language constructs. Some examples are only code fragments and will notcompile without additional code.

    Copyright IBM Corp. 1996, 2000 3

  • 8/9/2019 C CPP Reference Manual

    20/479

    IBM OS/390 C/C++ and Related Publications

    This section summarizes the content of the IBM OS/390 C/C++ publications andshows where to find related information in other publications.

    Table 1. OS/390 C/C++ Publications

    Book Title and Number Key Sections/Chapters in the Book

    OS/390 C/C++ Programming Guide,SC09-2362

    Guidance information for:v C/C++ input and outputv Debugging OS/390 C programs that use input/output

    v Using linkage specifications in C++

    v Combining C and assembler

    v Creating and using DLLs

    v Using threads in an OS/390 UNIX application

    v Reentrancyv Using the decimal data type in C and C++v Handling exceptions, error conditions, and signalsv Optimizing codev Optimizing your C/C++ code with Interprocedural Analysis

    v Network communications under OS/390 UNIX

    v Interprocess communications using OS/390 UNIX

    v Structuring a program that uses C++ templates

    v Using environment variables

    v Using System Programming C facilitiesv Library functions for the System Programming C facilitiesv Using runtime user exitsv Using the OS/390 C multitasking facility

    v Using other IBM products with OS/390 C/C++ (CICS, CSP, DWS, DB2,GDDM, IMS, ISPF, QMF)

    v Internationalization: locales and character sets, code set conversion utilities,mapping variant characters

    v POSIX character setv Code point mappingsv Locales supplied with OS/390 C/C++v Charmap files supplied with OS/390 C/C++v Examples of charmap and locale definition source files

    v Converting code from coded character set IBM-1047

    v Using built-in functions

    v Programming considerations for OS/390 UNIX C/C++

    OS/390 C/C++ Users Guide,SC09-2361

    Guidance information for:v OS/390 C/C++ examplesv Compiler options

    v Binder options and control statements

    v Specifying OS/390 Language Environment runtime options

    v Compiling, IPA Linking, binding, and running OS/390 C/C++ programs

    v Using precompiled headers

    v Utilities (Object Library, DLL Rename, CXXFILT, DSECT Conversion, CodeSet and Locale, ar and make, BPXBATCH)

    v Diagnosing problemsv Cataloged procedures and REXX EXECs supplied by IBM

    v Error messages and return codes

    4 OS/390 V2R10.0 C/C++ Language Reference

    http://cbcpg030.pdf/http://cbcpg030.pdf/http://cbcpg030.pdf/http://cbcug030.pdf/http://cbcug030.pdf/http://cbcug030.pdf/http://cbcug030.pdf/http://cbcug030.pdf/http://cbcpg030.pdf/http://cbcpg030.pdf/
  • 8/9/2019 C CPP Reference Manual

    21/479

    Table 1. OS/390 C/C++ Publications (continued)

    Book Title and Number Key Sections/Chapters in the Book

    OS/390 C/C++ Language Reference,SC09-2360

    Reference information for:

    v The C and C++ languages

    v Lexical elements of OS/390 C and OS/390 C++

    v Declarations, expressions, and operators

    v Implicit type conversionsv Functions and statementsv Preprocessor directivesv C++ classes, class members, and friends

    v C++ overloading, special member functions, and inheritance

    v C++ templates and exception handling

    v OS/390 C and OS/390 C++ compatibility

    OS/390 C/C++ Run-Time Library

    Reference, SC28-1663Reference information for:v C header filesv C Library functions

    OS/390 C Curses, SC28-1907 Reference information for:

    v Curses concepts

    v Key data typesv General rules for characters, renditions, and window propertiesv General rules of operations and operating modesv Use of macrosv Restrictions on block-mode terminals

    v Curses functional interface

    v Contents of headers

    v The terminfo database

    OS/390 C/C++ Compiler and

    Run-Time Migration Guide,SC09-2359

    Guidance and reference information for:v Common migration questionsv Application executable program compatibility

    v Source program compatibility

    v Input and output operations compatibility

    v Class library migration considerations

    v Changes between releases of OS/390

    v C/370 to current compiler migration

    v Other migration considerations

    OS/390 C/C++ Reference Summary,SX09-1313

    Summary tables for:

    v Character set, trigraphs, digraphs, and keywords

    v Escape sequences, storage classes

    v Predefined and derived types, type qualifiers

    v Operator precedence, redirection symbols

    v fprintf()format, type characters, and flag charactersv fscanf()format and type charactersv __amrc structurev Hardware exceptions and signals

    v Compiler return codes

    v Compiler options

    v #pragma directives

    v Library functions

    v Utilities

    Chapter 1. About This Book 5

    http://cbclr030.pdf/http://cbclr030.pdf/http://cbclr030.pdf/http://cbcrs020.pdf/http://cbcrs020.pdf/http://cbcrs020.pdf/http://cbcrs020.pdf/http://cbcrs020.pdf/http://cbcmg030.pdf/http://cbcmg030.pdf/http://cbcmg030.pdf/http://bpxbbm01.pdf/http://edclb030.pdf/http://edclb030.pdf/http://cbclr030.pdf/http://cbclr030.pdf/
  • 8/9/2019 C CPP Reference Manual

    22/479

    Table 1. OS/390 C/C++ Publications (continued)

    Book Title and Number Key Sections/Chapters in the Book

    OS/390 C/C++ IBM Open Class

    Library Users Guide, SC09-2363Guidance information for:

    v Using the Complex Mathematics Class Library: Review of complexnumbers, header files, constructing complex objects, mathematicaloperators for complex, friend functions for complex, handling complexmathematics errors

    v Using the I/O Stream Class Library: Introduction, getting started, advancedtopics, and manipulators

    v Using the Collection Class Library: Overview, instantiating and using,element and key functions, tailoring a collection implementation,polymorphic use of collections, support for notifications, exception handling,tutorials, problem solving, compatibility with previous releases, thread safety

    v Using the Application Support Class Library: Introduction, String classes,Exception and Trace classes, Date and Time classes, controlling threadsand protecting data, the IBM Open Class* notification framework, BinaryCoded (Packed) Decimal classes

    OS/390 C/C++ IBM Open Class

    Library Reference, SC09-2364Reference information for:

    v Complex Mathematics Class Library

    v I/O Stream Class Library

    v Collection Class Library

    v Application Support Class Library

    Debug Tool Users Guide and

    Reference, SC09-2137Guidance and reference information for:

    v Preparing to debug programs

    v Debugging programs

    v Using Debug Tool in different environments

    v Language-specific information

    v Debug Tool reference

    APAR and BOOKS files (Shipped withProgram materials)

    Partitioned data set CBC.SCBCDOC on the product tape contains themembers, APAR and BOOKS, which provide additional information for usingthe IBM OS/390 C/C++ licensed program, including:

    v Isolating reportable problems

    v Keywords

    v Preparing an Authorized Program Analysis Report (APAR)

    v Problem identification worksheetv Maintenance on OS/390v Late changes to OS/390 C/C++ publications

    Note: For complete and detailed information on linking and running with OS/390 Language Environment and usingthe OS/390 Language Environment runtime options, refer to OS/390 Language Environment Programming Guide,SC28-1939. For complete and detailed information on using interlanguage calls, refer to OS/390 LanguageEnvironment Writing Interlanguage Applications, SC28-1943.

    The following table lists the OS/390 C/C++ and related publications. The tablegroups the publications according to the tasks they describe.

    Table 2. Publications by Task

    Tasks Books

    Planning, preparing, and migrating to OS/390C/C++

    v OS/390 C/C++ Compiler and Run-Time Migration Guide,SC09-2359

    v OS/390 Language Environment Customization, SC28-1941

    v OS/390 UNIX System Services Planning, SC28-1890

    v OS/390 Planning for Installation, GC28-1726

    v OS/390 Task Atlas, available on the OS/390 Library page on theWorld Wide Web (http://www.ibm.com/s390/os390/bkserv/)

    6 OS/390 V2R10.0 C/C++ Language Reference

    http://cbcocu03.pdf/http://cbcocu03.pdf/http://cbcocu03.pdf/http://cbcocu03.pdf/http://cbcocu03.pdf/http://ceea2030.pdf/http://ceea2030.pdf/http://ceea2030.pdf/http://ceea4030.pdf/http://ceea4030.pdf/http://ceea4030.pdf/http://bpxb20b0.pdf/http://bpxb20b0.pdf/http://e0z1a240.pdf/http://e0z1a240.pdf/http://e0z1a240.pdf/http://bpxb20b0.pdf/http://ceea5030.pdf/http://cbcmg030.pdf/http://cbcmg030.pdf/http://ceea4030.pdf/http://ceea4030.pdf/http://ceea2030.pdf/http://ceea2030.pdf/http://cbcdt030.pdf/http://cbcdt030.pdf/http://cbccr010.pdf/http://cbccr010.pdf/http://cbcocu03.pdf/http://cbcocu03.pdf/
  • 8/9/2019 C CPP Reference Manual

    23/479

    Table 2. Publications by Task (continued)

    Tasks Books

    Installing v OS/390 Program Directory

    v OS/390 Planning for Installation, GC28-1726

    v OS/390 Language Environment Customization, SC28-1941

    Coding programs v OS/390 C/C++ Run-Time Library Reference, SC28-1663v

    OS/390 C/C++ Language Reference, SC09-2360v OS/390 C/C++ Reference Summary, SX09-1313

    v OS/390 C/C++ Programming Guide, SC09-2362

    v OS/390 Language Environment Concepts Guide, GC28-1945

    v OS/390 Language Environment Programming Guide, SC28-1939

    v OS/390 Language Environment Programming Reference,SC28-1940

    v OS/390 C/C++ IBM Open Class Library Users Guide, SC09-2363v OS/390 C/C++ IBM Open Class Library Reference, SC09-2364

    Coding and binding programs withinterlanguage calls

    v OS/390 C/C++ Programming Guide, SC09-2362

    v OS/390 C/C++ Language Reference, SC09-2360

    v OS/390 Language Environment Programming Guide, SC28-1939

    v OS/390 Language Environment Writing Interlanguage Applications,SC28-1943

    v OS/390 DFSMS Program Management, SC27-0806

    Compiling, binding, and running programs v OS/390 C/C++ Users Guide, SC09-2361

    v OS/390 Language Environment Programming Guide, SC28-1939

    v OS/390 Language Environment Debugging Guide and Run-Time

    Messages, SC28-1942

    v OS/390 DFSMS Program Management, SC27-0806v OS/390 Messages Database, available on the OS/390 Library page

    on the World Wide Web (http://www.ibm.com/s390/os390/bkserv/)

    Compiling and binding applications in theOS/390 UNIX environment

    v OS/390 C/C++ Users Guide, SC09-2361

    v OS/390 UNIX System Services Users Guide, SC28-1891

    v OS/390 UNIX System Services Command Reference, SC28-1892

    v OS/390 DFSMS Program Management, SC27-0806

    Debugging programs v README filev Debug Tool Users Guide and Reference, SC09-2137

    v OS/390 C/C++ Users Guide, SC09-2361

    v OS/390 C/C++ Programming Guide, SC09-2362

    v OS/390 Language Environment Programming Guide, SC28-1939

    v OS/390 Language Environment Debugging Guide and Run-Time

    Messages, SC28-1942v OS/390 UNIX System Services Messages and Codes, SC28-1908v OS/390 UNIX System Services Users Guide, SC28-1891v OS/390 UNIX System Services Command Reference, SC28-1892v OS/390 UNIX System Services Programming Tools, SC28-1904

    Using shells and utilities in the OS/390 UNIXenvironment

    v OS/390 C/C++ Users Guide, SC09-2361

    v OS/390 UNIX System Services Command Reference, SC28-1892

    v OS/390 UNIX System Services Messages and Codes, SC28-1908

    Using sockets library functions in the OS/390UNIX environment

    v OS/390 C/C++ Run-Time Library Reference, SC28-1663

    Chapter 1. About This Book 7

    http://e0z1a240.pdf/http://e0z1a240.pdf/http://ceea5030.pdf/http://ceea5030.pdf/http://edclb030.pdf/http://edclb030.pdf/http://cbclr030.pdf/http://cbclr030.pdf/http://cbcrs020.pdf/http://cbcrs020.pdf/http://cbcpg030.pdf/http://cbcpg030.pdf/http://ceea8030.pdf/http://ceea8030.pdf/http://ceea2030.pdf/http://ceea2030.pdf/http://ceea3030.pdf/http://ceea3030.pdf/http://ceea3030.pdf/http://cbcdt030.pdf/http://cbcdt030.pdf/http://cbcdt030.pdf/http://cbcdt030.pdf/http://cbcug030.pdf/http://cbcug030.pdf/http://cbcug030.pdf/http://cbcug030.pdf/http://cbcpg030.pdf/http://cbcpg030.pdf/http://ceea2030.pdf/http://ceea2030.pdf/http://ceea1030.pdf/http://ceea1030.pdf/http://ceea1030.pdf/http://bpxa8090.pdf/http://bpxa8090.pdf/http://bpxa4090.pdf/http://bpxa4090.pdf/http://bpxa4090.pdf/http://bpxa4090.pdf/http://bpxa5090.pdf/http://bpxa5090.pdf/http://bpxa6070.pdf/http://bpxa6070.pdf/http://cbcug030.pdf/http://cbcug030.pdf/http://cbcug030.pdf/http://cbcug030.pdf/http://bpxa5090.pdf/http://bpxa5090.pdf/http://bpxa8090.pdf/http://bpxa8090.pdf/http://edclb030.pdf/http://edclb030.pdf/http://edclb030.pdf/http://bpxa8090.pdf/http://bpxa5090.pdf/http://cbcug030.pdf/http://bpxa6070.pdf/http://bpxa5090.pdf/http://bpxa4090.pdf/http://bpxa8090.pdf/http://ceea1030.pdf/http://ceea1030.pdf/http://ceea2030.pdf/http://cbcpg030.pdf/http://cbcug030.pdf/http://cbcdt030.pdf/http://dgt1m610.pdf/http://bpxa5090.pdf/http://bpxa4090.pdf/http://cbcug030.pdf/http://dgt1m610.pdf/http://ceea1030.pdf/http://ceea1030.pdf/http://ceea2030.pdf/http://cbcug030.pdf/http://dgt1m610.pdf/http://ceea4030.pdf/http://ceea4030.pdf/http://ceea2030.pdf/http://cbclr030.pdf/http://cbcpg030.pdf/http://cbccr010.pdf/http://cbcocu03.pdf/http://ceea3030.pdf/http://ceea3030.pdf/http://ceea2030.pdf/http://ceea8030.pdf/http://cbcpg030.pdf/http://cbcrs020.pdf/http://cbclr030.pdf/http://edclb030.pdf/http://ceea5030.pdf/http://e0z1a240.pdf/
  • 8/9/2019 C CPP Reference Manual

    24/479

    Table 2. Publications by Task (continued)

    Tasks Books

    Porting a UNIX Application to OS/390v OS/390 UNIX System Services Porting Guide

    This guide contains useful information about supported header filesand C functions, sockets in an OS/390 UNIX environment, processmanagement, compiler optimization tips, and suggestions for

    improving the applications performance after it has been ported.The Porting Guideis available as a PDF file which you candownload, or as web pages which you can browse, at the followingweb address: http://www.ibm.com/s390/unix/bpxa1por.html

    Working in the OS/390 UNIX System ServicesParallel Environment

    v OS/390 UNIX System Services Parallel Environment: Operation

    and Use, SC33-6697

    v OS/390 UNIX System Services Parallel Environment: MPI

    Programming and Subroutine Reference, SC33-6696

    Performing diagnosis and submitting anAuthorized Program Analysis Report (APAR)

    v OS/390 C/C++ Users Guide, SC09-2361v CBC.SCBCDOC(APAR) on OS/390 C/C++ product tape

    Tuning Large C/C++ Applications on OS/390UNIX System Services

    v IBM Redbook called Tuning Large C/C++ Applications on OS/390UNIX System Services, which is available at:

    http://www.redbooks.ibm.com/abstracts/sg245606.htmlQuick reference v OS/390 C/C++ Reference Summary, SX09-1313

    Note: For information on using the prelinker, see the appendix on prelinking and linking OS/390 C/C++ programs inOS/390 C/C++ Users Guide. As of Release 4, this appendix contains information that was previously in the chapter onprelinking and linking OS/390 C/C++ programs in OS/390 C/C++ Users Guide. It also contains prelinker informationthat was previously in OS/390 C/C++ Programming Guide.

    Hardcopy Books

    The following OS/390 C/C++ books are available in hardcopy:v OS/390 C/C++ Run-Time Library Reference, SC28-1663v OS/390 C/C++ Users Guide

    , SC09-2361v OS/390 C/C++ Programming Guide, SC09-2362v OS/390 C/C++ Reference Summary, SX09-1313v OS/390 C/C++ IBM Open Class Library Users Guide, SC09-2363v OS/390 C Curses, SC28-1907v OS/390 C/C++ Compiler and Run-Time Migration Guide, SC09-2359v Debug Tool Users Guide and Reference, SC09-2137

    You can purchase these books on their own, or as part of a set. You receiveOS/390 C/C++ Compiler and Run-Time Migration Guide, SC09-2359at no charge.Feature code 8009 includes the remaining books.

    PDF Books

    All of the OS/390 C/C++ publications are supplied in PDF format. The books areavailable on a CD-ROM called OS/390 PDF Library Collection, SK2T-6718. Theyare also available at the following Web Site:

    http://www.ibm.com/software/ad/c390/cmvsdocs.html

    To read a PDF file, use the Adobe Acrobat Reader. If you do not have the AdobeAcrobat Reader, you can download it for free from the Adobe Web Site:

    http://www.adobe.com

    8 OS/390 V2R10.0 C/C++ Language Reference

    |

    |

    |

    |

    |

    http://ipeoue20.pdf/http://ipeoue20.pdf/http://ipeoue20.pdf/http://cbcmg030.pdf/http://cbcmg030.pdf/http://cbcmg030.pdf/http://cbcdt030.pdf/http://cbcmg030.pdf/http://bpxbbm01.pdf/http://cbcocu03.pdf/http://cbcrs020.pdf/http://cbcpg030.pdf/http://cbcug030.pdf/http://edclb030.pdf/http://cbcpg030.pdf/http://cbcug030.pdf/http://cbcug030.pdf/http://cbcrs020.pdf/http://cbcug030.pdf/http://asspre10.pdf/http://asspre10.pdf/http://ipeoue20.pdf/http://ipeoue20.pdf/
  • 8/9/2019 C CPP Reference Manual

    25/479

    Softcopy Books

    All of the OS/390 C/C++ publications (except for OS/390 C/C++ ReferenceSummary) are available in softcopy book format. The books are available on thetape that accompanies the OS/390 product, and on a CD-ROM called IBM OnlineLibrary Omnibus Edition OS/390 Collection, SK2T-6700.

    To read the softcopy books, use BookManager READ/MVS Version 1 Release 3(5695-046) or the Library Reader for DOS, OS/2 or Windows supplied on theCD-ROMs containing BookManager books.

    If your system has BookManager Read installed, you can enter the commandBOOKMGR to start BookManager and display a list of books available to you. If youknow the name of the book that you want to view, you can use the OPENcommand to open the book directly.

    Note: If your workstation does not have graphics capability, BookManager Readcannot correctly display some characters, such as arrows and brackets.

    You can also browse the books on the World Wide Web by clicking on "The Library"link on the OS/390 home page. The web address for this page is:

    http://www.ibm.com/s390/os390

    Softcopy Examples

    Most of the larger examples in the following books are available inmachine-readable form:v OS/390 C/C++ Language Reference, SC09-2360v OS/390 C/C++ Users Guide, SC09-2361v OS/390 C/C++ Programming Guide, SC09-2362v OS/390 C/C++ IBM Open Class Library Users Guide, SC09-2363v OS/390 C/C++ IBM Open Class Library Reference, SC09-2364

    In the following books, a label on an example indicates that the example isdistributed in softcopy. The label is the name of a member in the data setsCBC.SCBCSAMor CBC.SCLBSAM. The labels have the form CBCxyyyor CLBxyyy, wherexrefers to a publication:v R and X refer toOS/390 C/C++ Language Reference, SC09-2360v G refers to OS/390 C/C++ Programming Guide, SC09-2362v U refers to OS/390 C/C++ Users Guide, SC09-2361v A refers toOS/390 C/C++ IBM Open Class Library Users Guide, SC09-2363

    Examples labelled as CBCxyyyappear in OS/390 C/C++ Language Reference,OS/390 C/C++ Programming Guide, and OS/390 C/C++ Users Guide. Exampleslabelled as CLBxyyyappear in OS/390 C/C++ IBM Open Class Library Users

    Guide.

    An exception applies to the example names for the Collection Class Library whichdo not follow a naming convention. These examples are in OS/390 C/C++ IBMOpen Class Library Reference, SC09-2364.

    Chapter 1. About This Book 9

    |

    |

    |

    http://cbcrs020.pdf/http://cbcrs020.pdf/http://cbclr030.pdf/http://cbclr030.pdf/http://cbcug030.pdf/http://cbcug030.pdf/http://cbcug030.pdf/http://cbcug030.pdf/http://cbcpg030.pdf/http://cbcpg030.pdf/http://cbcocu03.pdf/http://cbcocu03.pdf/http://cbcocu03.pdf/http://cbcocu03.pdf/http://cbccr010.pdf/http://cbccr010.pdf/http://cbclr030.pdf/http://cbclr030.pdf/http://cbcpg030.pdf/http://cbcpg030.pdf/http://cbcug030.pdf/http://cbcug030.pdf/http://cbcug030.pdf/http://cbcug030.pdf/http://cbcocu03.pdf/http://cbcocu03.pdf/http://cbcocu03.pdf/http://cbcocu03.pdf/http://cbccr010.pdf/http://cbccr010.pdf/http://cbcocu03.pdf/http://cbcocu03.pdf/http://cbcug030.pdf/http://cbcpg030.pdf/http://cbclr030.pdf/http://cbcocu03.pdf/http://cbcug030.pdf/http://cbcpg030.pdf/http://cbclr030.pdf/http://cbccr010.pdf/http://cbcocu03.pdf/http://cbcpg030.pdf/http://cbcug030.pdf/http://cbclr030.pdf/http://cbcrs020.pdf/http://cbcrs020.pdf/
  • 8/9/2019 C CPP Reference Manual

    26/479

    OS/390 C/C++ on the World Wide Web

    Additional information on OS/390 C/C++ is available on the World Wide Web on theOS/390 C/C++ home page at:

    http://www.ibm.com/software/ad/c390

    This page contains late-breaking information about the OS/390 C/C++ product,

    including the compiler, the class libraries, and utilities. It also contains a tutorial onthe source level interactive debugger. There are links to other useful information,such as the OS/390 C/C++ information library and the libraries of other OS/390elements that are available on the Web. The OS/390 C/C++ home page alsocontains samples that you can download, and links to other related Web sites.

    How to Read the Syntax Diagrams

    This book describes the syntax for commands, directives, and statements, using thefollowing structure:

    v Read the syntax diagrams from left to right, from top to bottom, following the pathof the line.

    A double right arrowhead indicates the beginning of a command, directive, orstatement. A single right arrowhead indicates that it is continued on the next line.In the following diagrams, "statement" represents a command, directive, orstatement.

    statement

    v Required items are on the horizontal line (the main path).

    statement required_item

    v Optional items are below the main path.

    statementoptional_item

    v If you can choose from two or more items, they are vertical in a stack.

    If you mustchoose one of the items, one item of the stack is on the main path.

    statement required_choice1required_choice2

    If choosing one of the items is optional, the entire stack is below the main path.

    statementoptional_choice1optional_choice2

    v An arrow that returns to the left above the main line indicates an item that youcan repeat.

    10 OS/390 V2R10.0 C/C++ Language Reference

  • 8/9/2019 C CPP Reference Manual

    27/479

    statement repeatable_item

    A repeat arrow above a stack indicates that you can make more than one choicefrom the stacked items, or repeat a single choice.

    v Keywords are not italicized, and should be entered exactly as shown (forexample,pragma). You must spell keywords exactly as shown in the syntaxdiagram. Variables are in lowercase italics (in hardcopy), for example, identifier.They represent user-supplied names or values.

    v If the syntax diagram shows punctuation marks, parentheses, arithmeticoperators, or other nonalphanumeric characters, you must enter them as part ofthe syntax.

    Note: You do not always require the white space between tokens. You should,however, include at least one blank space between tokens unless otherwisespecified.

    The following syntax diagram example shows the syntax for the #pragma commentdirective.

    (1) (2) (3)

    # pragma(4)

    comment

    (5) (6) (9) (10)

    ( compiler )datetimestamp

    copyrightuser (7) (8)

    , " token_sequence "

    Notes:

    1 This is the start of the syntax diagram.

    2 The symbol# must appear first.

    3 The keywordpragmamust follow the # symbol.

    4 The keywordcomment must follow the keyword pragma.

    5 An opening parenthesis must follow the keywordcomment.

    6 The comment type must be entered only as one of the following:compiler,date,timestamp,copyright, oruser.

    7 If the comment type iscopyright or user, and an optional character string isfollowing, a comma must be present after the comment type.

    8 A character string must follow the comma. The character string must beenclosed in double quotation marks.

    9 A closing parenthesis is required.

    10 This is the end of the syntax diagram.

    The following examples of the #pragma comment directive are syntactically correctaccording to the diagram above:

    Chapter 1. About This Book 11

  • 8/9/2019 C CPP Reference Manual

    28/479

    #pragma comment(date)#pragma comment(user)#pragma comment(copyright,"This text will appear in the module")

    12 OS/390 V2R10.0 C/C++ Language Reference

  • 8/9/2019 C CPP Reference Manual

    29/479

    Chapter 2. About IBM OS/390 C/C++

    The C/C++ feature of the IBM OS/390 licensed program provides support for C andC++ application development on the OS/390 platform. The C/C++ feature is basedon the C/C++ for MVS/ESA product.

    IBM OS/390 C/C++ includes:v A C compiler (referred to as the OS/390 C compiler)v A C++ compiler (referred to as the OS/390 C++ compiler)v Support for a set of C++ class libraries that are available with the base OS/390

    operating systemv Application Support Class and Collection Class Library sourcev A mainframe interactive Debug Tool (optional)v Performance Analyzer host component, which supports the C/C++ Productivity

    Tools for OS/390 productv A set of utilities for C/C++ application development

    IBM offers the C language on other platforms, such as the AIX, OS/2, OS/400,

    VM/ESA

    , VSE/ESA, and Windows operating systems. The AIX, OS/2, OS/400, andWindows operating systems also offer the C++ language.

    Changes for Version 2 Release 10

    OS/390 C/C++ has made the following performance and usability enhancements forthis release:

    Extra Performance Linkage (XPLINK)Extra Performance Linkage (XPLINK) is a new call linkage betweenfunctions that has the potential for a significant performanceincrease when used in an environment of frequent calls betweensmall functions. XPLINK makes subroutine calls more efficient byremoving nonessential instructions from the main path. When allfunctions are compiled with the XPLINK option, pointers can beused without restriction, which makes it easier to port newapplications to S/390.

    GOFF The Generalized Object File Format (GOFF) is the strategic objectmodule format for S/390. It extends the capabilities of objectmodules to contain more information than current object modules. Itremoves the limitations of the previous object module format andsupports future enhancements. GOFF makes re-binding easier andmore efficient. It is required for XPLINK.

    IPA Level 2 Under IPA Level 1, many optimizations such as constantpropagation and pointer analysis are performed at the

    intraprocedural (subprogram) level. With IPA Level 2, theseoptimizations are performed across the entire program, which canresult in significant improvement in the generated code.

    Addition of @STATIC Map into Compiler ListingThe @STATIC Map displays offset information for file scoperead/write static variables.

    This release has introduced the following compiler option:

    COMPACT During optimizations performed during code generation, for bothNOIPA and IPA, choices must be made between those

    Copyright IBM Corp. 1996, 2000 13

    |

    |

    |

    |

    |

    |

    |

    |

    |

    |

    |

    |

    ||

    |

    |

    |

    |

    |

    ||

    |

    |

    |

    |

    |

    |

    |

    |

    ||

    |

  • 8/9/2019 C CPP Reference Manual

    30/479

    optimizations which tend to result in faster but larger code andthose which tend to result in smaller but slower code. The COMPACT| NOCOMPACT option controls these choices. When the COMPACToption is used, the compiler favors those optimizations which tendto limit the growth of the code. This feature gives you the flexibilityto choose between faster but larger code or slower and smallercode.

    For details on how to use this compiler option, see the chapter Compiler OptionsinOS/390 C/C++ Users Guide.

    The IBM System Object Model (SOM) is no longer supported in the C++ compilerand the IBM Open Class Library. The SOM-enabled class library DLLs have beenstabilized at the V2R9 level and continue to be shipped as a run-time environmentonly. You cannot use the V2R10 Compiler to build SOM applications.

    The Model Tool is no longer available.

    The option_override #pragma directive defines function-specific options thatoverride those specified by the command line options when performing optimization

    for code and data in that subprogram. This enables finer control of programoptimization. In V2R10 we have added support for the COMPACTand SPILL options.The subprogram-specificSPILL option is not a new option, however, the maximumspill area size has been increased for this release to 1073741823 bytes or 2301bytes.

    OS/390 Language Environment Downward CompatibilityOS/390 Release 10 Language Environment provides downward compatibilitysupport. Assuming that you have met the required programming guidelines andrestrictions, described in OS/390 Language Environment Programming Guide, thissupport enables you to develop applications on higher release levels of OS/390 foruse on platforms that are running lower release levels of OS/390. In C and C++,

    downward compatibility support is provided through the C/C++ TARGET compileroption. See the OS/390 C/C++ Users Guidefor details on this compiler option.

    For example, a company may use OS/390 Release 10 with Language Environmenton a development system where applications are coded, link-edited, and tested,while using any supported lower release of OS/390 Language Environment on theirproduction systems where the finished application modules are used.

    Downward compatibility support is not the roll-back of new function to prior releasesof OS/390. Applications developed that exploit the downward compatibility supportmust not use any Language Environment function that is unavailable on the lowerrelease of OS/390 where the application will be used.

    The downward compatibility support includes toleration PTFs for lower releases ofOS/390 to assist in diagnosing applications that do not meet the programmingrequirements for this support. (Specific PTF numbers can be found in the PSPbuckets.)

    The downward compatibility support provided by OS/390 Release 10 and by thetoleration PTFs does not change Language Environments upward compatibility.That is, applications coded and link-edited with one release of OS/390 LanguageEnvironment will continue to run on later releases of OS/390 Language

    14 OS/390 V2R10.0 C/C++ Language Reference

    |

    |

    |