C Language expressions and operators

Related Publications
Obtaining Publications
Conventions
Reader Comments
1. An Overview of ANSI C
ANSI C
Strictly Conforming Programs
Name Spaces
Compiling ANSI Programs
Guidelines for Using ANSI C
Compiling Traditional C Programs
Helpful Programming Hints
Recommended Practices
Practices to Avoid
2. C Language Changes
Preprocessor Changes
Replacement of Macro Arguments in Strings
Token Concatenation
Changes in Disambiguating Identifiers
Scoping Differences
Name Space Changes
Changes in the Linkage of Identifiers
Types and Type Compatibility
Type Promotion in Arithmetic Expressions
Type Promotion and Floating Point Constants
Compatible Types
Argument Type Promotions
Mixed Use of Functions
Function Prototypes
External Name Changes
Changes in Function Names
Changes in Linker-Defined Names
Data Area Name Changes
Standard Headers
3. Lexical Conventions
Comments
Identifiers
Keywords
Constants
Integer Constants
Character Constants
Special Characters
Trigraph Sequences (ANSI C Only)
Floating Constants
Enumeration Constants
String Literals
Operators
Punctuators
4. Meaning of Identifiers
Disambiguating Names
Scope
Block Scope
Function Scope
Function Prototype Scope
File Scope
Name Spaces
Name Space Discrepancies Between Traditional a
Linkage of Identifiers
Linkage Discrepancies Between Traditional and AN
Storage Duration
Object Types
Character Types
Integer and Floating Point Types
Derived Types
voidType
Objects and lvalues
5. Operator Conversions
Conversions of Characters and Integers
Conversions of Float and Double
Conversion of Floating and Integral Types
Conversion of Pointers and Integers
Conversion ofunsignedIntegers
Arithmetic Conversions
Integral Promotions
Usual Arithmetic Conversions
Traditional C Conversion Rules
ANSI C Conversion Rules
Conversion of Other Operands
Conversion of lvalues and Function Designators
Conversion ofvoidObjects
Conversion of Pointers
6. Expressions and Operators
Precedence and Associativity Rules in C
Primary Expressions
Postfix Expressions
Subscripts
Function Calls
Structure and Union References
Indirect Structure and Union References
postfix ++andpostfix – –
Unary Operators
Address-of and Indirection Operators
Unary+and-Operators
Unary!and~Operators
Prefix++and –Operators
sizeofUnary Operator
Cast Operators
Multiplicative Operators
Additive Operators
Shift Operators
Relational Operators
Equality Operators
Bitwise AND Operator
Bitwise Exclusive OR Operator
Bitwise Inclusive OR Operator
Logical AND Operator
Logical OR Operator
Conditional Operator
Assignment Operators
Assignment Using = (Simple Assignment)
Compound Assignment
Comma Operator
Constant Expressions
Integer and Floating Point Exceptions
7. Declarations

An Overview of ANSI C

This chapter briefly discusses the scope of the standard and lists some programming practices to avoid and some practices to use.
ANSI C
The ANSI standard on the C programming language is designed to promote the portability of C programs among a variety of data-processing systems. To accomplish this, the standard covers three major areas: the environment in which the program compiles and executes, the semantics and syntax of the language, and the content and semantics of a set of library routines and headerfiles.
Strictly Conforming Programs
Strictly conforming programs adhere to the following guidelines:
• They use only those features of the language defined in the standard.
• They do not produce output dependent on any ill-defined behavior. Ill-defined behavior includes implementation-defined, undefined, and unspecified behavior which refers to areas that the standard does not specify.
• They do not exceed any minimum limit.
This ANSI C environment is designed to be a conforming hosted implementation,which will accept any strictly conforming program. Extensions are allowed only if the behavior of strictly conforming programs is not altered.
Name Spaces
In addition to knowing which features of the language and library you can rely on when writing portable programs, you must be able to avoid naming conflicts with support routines used for the implementation of the library. To avoid such naming conflicts, ANSI divides the space of available names into a set reserved for the user and a set reserved for the implementation. Any name is in the user’s name space if it meets these three requirements (this rule is given for simplicity; the space of names reserved for the user is actually somewhat larger than this):
Compiling ANSI Programs
To provide the portable clean environment dictated by ANSI while retaining the many extensions available to SGI users, two modes of compilation are provided for ANSI programs. Each of these switches to thecccommand invokes the ANSI compiler:
-ansi Enforces a pure ANSI environment, eliminating SGI extensions. The ANSI symbol indicating a pure environment (__STDC__) is defined tobe 1 for the preprocessor. Use this mode when compiling strictly conforming programs, because it guarantees purity of the ANSI namespace.
Guidelines for Using ANSI C
The following are some key facts to keep in mind when you use ANSI C:
• Use only-lcand/or-lmto specify the C and/or math libraries. These switches ensure the incorporation of the ANSI version of these libraries.
• Use the switch-fullwarnto receive additional diagnostic warnings that are suppressed by default. SGI recommends using this option with the-woffoption to remove selected warnings during software development.
Guidelines for Using ANSI C
The following are some key facts to keep in mind when you use ANSI C:
• Use only-lcand/or-lmto specify the C and/or math libraries. These switches ensure the incorporation of the ANSI version of these libraries.
• Use the switch-fullwarnto receive additional diagnostic warnings that are suppressed by default. SGI recommends using this option with the-woffoption to remove selected warnings during software development.


Si le lien ne fonctionne pas correctement, veuillez nous contacter (mentionner le lien dans votre message)
C language reference manual (633 KO) (Cours PDF)
Cours C language

Télécharger aussi :

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *