ILE C for AS/400 Language Reference

ILE C for AS/400 Language Reference

AS/400e™ IBM ILECforAS/400® Language Reference Ve r s i o n 4 SC09-2711-01 AS/400e™ IBM ILECforAS/400® Language Reference Ve r s i o n 4 SC09-2711-01 Note Before using this information and the product it supports, be sure to read the general information under “Notices” on page xi. Second Edition (June 1999) This edition applies to Version 4, Release 4, Modification Level 0, of IBM Application System/400 ILE C (Program 5769-CX2) and to all subsequent releases and modifications until otherwise indicated in new editions. Make sure you are using the proper edition for the level of the product. This edition replaces SC09–2711–00. Changes or additions to the text and illustrations are indicated by a vertical line to the left of the change or addition. Order publications through your IBM representative or the IBM branch office serving your locality. Publications are not stocked at the address given below. IBM welcomes your comments. You can send your comments to: IBM Canada Ltd. Laboratory, 2G/KB7/1150/TOR 1150 Eglinton Avenue East Toronto, Ontario, Canada. M3C 1H7 You can also send your comments by facsimile (attention: RCF Coordinator), or you can send your comments electronically to IBM. See “How to Send Your Comments” on page xiv for a description of the methods. 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 1993, 1999. All rights reserved. US Government Users Restricted Rights – Use duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. Contents Tables ........................... ix Notices ........................... xi Programming Interface Information ................. xii Trademarks and Service Marks .................. xii Industry Standards ....................... xii About This Book .......................xiii Who Should Use This Book ....................xiii A Note About Examples ....................xiv How to Send Your Comments ...................xiv Chapter 1. Introduction to C ................... 1 Overview of the C Language ................... 1 C Source Programs ....................... 1 C Source Files ........................ 2 Program Processing ...................... 3 Scope ............................ 4 Linkage ........................... 6 Storage Duration ........................ 7 Name Spaces ......................... 7 Chapter 2. Lexical Elements of C ................. 9 Character Set ......................... 9 Trigraphs........................... 9 Escape Sequences .......................10 Comments .......................... 11 Identifiers ..........................12 Keywords ..........................13 Constants..........................14 Integer Constants ......................14 Decimal Constants ......................15 Hexadecimal Constants ....................15 Octal Constants .......................16 Floating-Point Constants ....................17 Character Constants .....................18 Packed Decimal Constants ...................19 Strings ..........................20 Enumeration Constants....................22 Chapter 3. Declarations and Definitions ..............23 Block Scope Data Declarations ..................23 File Scope Data Declarations ...................24 Storage Class Specifiers .....................25 auto Storage Class Specifier ...................25 extern Storage Class Specifier ...................28 Declaration ..........................28 register Storage Class Specifier ..................30 static Storage Class Specifier ...................31 Declarators ..........................33 volatile and const Qualifiers ....................35 _Packed Qualifier .......................36 Initializers ..........................37 © Copyright IBM Corp. 1993, 1999 iii Types ............................38 Characters ..........................38 Floating-Point Variables .....................39 Integers ...........................40 Packed Decimal ........................42 void Type ..........................43 Enumerations .........................44 Declaring an Enumeration Data Type ...............44 Defining a Variable That Has an Enumeration Type ..........45 Example of Defining an Enumeration Type and Enumeration Objects . 45 Arrays ............................47 Type Specifiers of Arrays ....................47 Declarators of Arrays .....................47 Initializers of Arrays ......................48 Pointers ...........................52 Declarators of Pointers ....................52 Initializers of Pointers .....................53 Restrictions .........................54 Using Pointers........................54 Pointer Arithmetic ......................55 Structures ..........................57 Declaring a Structure Data Type .................57 Defining a Variable That Has a Structure Data Type ..........58 Storage Classes of Structures ..................58 Initializers of Structures ....................58 Example of Declaring a Structure Type and Structure Variables......59 Declaring and Using Bit Fields ..................60 Declaring a Packed Structure ..................61 Unions ...........................62 Declaring a Union ......................62 Example of Defining a Variable that Has Union Data Type .......63 Defining a Union Type and a Union Variable.............64 Defining a Packed Union ....................64 typedef ...........................66 Incomplete Types ......................67 Chapter 4. Functions ......................69 main ............................69 Function Definition .......................70 Function Declarator ......................72 Prototype Function Declarator ..................72 Nonprototype Function Declarator ................73 Parameter Declaration List ...................73 Function Body ........................74 Function Declarations ......................74 Calling Functions and Passing Arguments ..............76 Chapter 5. Expressions and Operators ...............79 Grouping and Evaluating Expressions ................79 Lvalue............................81 Constant Expression ......................82 Primary Expression .......................83 Parenthesized Expression ( ) ..................83 Function Call ( ) .......................84 Array Element Specification (Array Subscript) [ ] ...........85 Structure and Union Member Specification . −> ...........85 iv Language Reference Unary Expression .......................86 Increment ++ ........................86 Decrement −− ........................86 Unary Plus + ........................87 Unary Minus −........................87 Logical Negation ! ......................87 Bitwise Negation .......................88 Address & .........................88 Indirection *.........................88 Cast ...........................89 Size of an Object.......................89 Digits of an Object ......................90 Precision of an Object .....................90 Binary Expression .......................91 Multiplication *........................92 Division /..........................92 Remainder % ........................93 Addition + .........................93 Subtraction − ........................94 Bitwise Left and Right Shift << >> ................95 Relational<><=>= .....................96 Equality == != ........................97 Bitwise AND &........................98 Bitwise Exclusive OR | ....................99 Bitwise Inclusive OR ¦ .....................99 Logical AND && .......................99 Logical OR ¦¦ ........................100 Conditional Expression ? : ....................101 Assignment Expression .....................102 Simple Assignment = .....................102 Compound Assignment ....................103 Comma Expression , ......................104 Chapter 6. Conversions .....................105 Usual Arithmetic Conversions ...................105 Type Conversions .......................106 Assignment Conversions ....................106 From Signed Integer Types ...................106 From Unsigned Integer Types ..................109 From Floating-Point Types ...................112 To and From Pointer Types ...................116 From Other Types ......................117 Chapter 7. C Language Statements ................119 Labels............................119 Block ............................120 break ............................121 continue ...........................123 do.............................124 Expression ..........................125 for.............................125 goto ............................127 if..............................128 Null Statement.........................129 return ............................129 switch ............................131 Contents v while ............................134 Chapter 8. Preprocessor Directives ................137 Preprocessor Directive Format ...................137 #define ...........................138 Object-Like Macro Definition ..................138 Function-Like Macro Definition ..................138 #undef ...........................140 Predefined Macros .......................141 # Operator ..........................144 ## Operator..........................145 #error ............................146 #include ...........................147 Using the #include Directive When Compiling Source in an Integrated File System File ........................148 Conditional Compilation .....................149 #if, #elif ..........................150 #ifdef ...........................151 #ifndef...........................151

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    214 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us