## 表达式(Expressions)

### 主表达式(Primary expressions)

• identifier:标识符 例如：int a ; 这里 a就是标识符
• constant: 常量 (详见c99词法部分)
• string-literal:字符串字面值 (详见c99词法部分)

### 后缀运算符(Postfix operators)

1. Array subscripting (数组下标) 手册 P6.5.2.1

2. Function calls (函数调用) 手册 P6.5.2.2

3. Structure and union members (结构体和联合体成员) 手册 P6.5.2.3

4. Postfix increment and decrement operators (后缀++和— 运算符) 手册 P6.5.2.4

5. Compound literals (复合字面值) 手册 P6.5.2.5

#### compound literals

compound literals 是由一个带括号的类型名和一个大括号的初始值设定项列表组成。

### 一元运算符 (Unary operators)

1. Prefix increment and decrement operators(前缀++和—) 手册P6.5.3.1

2. Address and indirection operators 手册P6.5.3.2

3. Unary arithmetic operators (一元算数运算符) 手册P6.5.3.3

4. The sizeof operator (sizeof运算符) 手册P6.5.3.4

Constraints(约束条件):

### Multiplicative operators

Constraints(约束条件):

Constraints(约束条件):
1. 两个操作数都应为算术类型，或者一个操作数应为指向对象类型的指针，另一个操作数应为整数类型

2. 对于减法，应满足下列要求中的一项：

• 两个操作数都是算数类型。
• 两个操作数都是指向兼容对象类型的限定或非限定版本的指针。
• 左操作数是指向对象类型的指针，右边的操作数具有整数类型。

### Bitwise shift operators(移位运算符)

Constraints(约束条件):

### Relational operators (关系运算符)

Constraints(约束条件):

1. 两个操作数都是实数类型
2. 两个操作数都是指向兼容对象类型的限定或非限定版本的指针( both operands are pointers to qualified or unqualified versions of compatible object types)
3. both operands are pointers to qualified or unqualified versions of compatible incomplete types

### Equality operators

Constraints(约束条件):

1. 两个操作数都是算数类型
2. 两个操作数都是指向兼容类型的有限制或无限制版本的指针；(both operands are pointers to qualified or unqualified versions of compatible types)
3. one operand is a pointer to an object or incomplete type and the other is a pointer to a qualified or unqualified version of void
4. one operand is a pointer and the other is a null pointer constant

### Bitwise AND operator

Constraints(约束条件):

### Bitwise exclusive OR operator

Constraints(约束条件):

### Bitwise inclusive OR operator

Constraints(约束条件):

### Logical AND operator

Constraints(约束条件):

### Logical OR operator

Constraints(约束条件):

### Conditional operator (条件运算符)

Constraints(约束条件):
1. 第一个操作数应该是标量类型
2. 第二个和第三个操作数应满足以下条件之一：
• 两个操作数都具有算术类型；
• both operands have the same structure or union type
• both operands have void type
• both operands are pointers to qualified or unqualified versions of compatible types
• one operand is a pointer and the other is a null pointer constan
• one operand is a pointer to an object or incomplete type and the other is a pointer to a qualified or unqualified version of void

### Assignment operators (赋值运算符)

Constraints(约束条件):

### Comma operator

Semantics(语法):

The left operand of a comma operator is evaluated as a void expression;there is a sequence point after its evaluation. Then the right operand is evaluated; the result has its type and value. If an attempt is made to modify the result of a comma operator or to access it after the next sequence point, the behavior is undefined.

EXAMPLE(例子): As indicated by the syntax, the comma operator (as described in this subclause) cannot appear in contexts where a comma is used to separate items in a list (such as arguments to functions or lists of initializers). On the other hand, it can be used within a parenthesized expression or within the second expression of a conditional operator in such contexts. In the function call $$f(\quad a,\quad (t=3,\quad t+2),\quad c)$$ the function has three arguments, the second of which has the value 5. ## Constant expression **语法：** $$\begin{gather*} constant\texttt{-}expression: \\ conditional\texttt{-}expression \end{gather*}$$ **文档P6.6** Description(描述):

A constant expression can be evaluated during translation rather than runtime, and accordingly may be used in any place that a constant may be.(常量表达式在编译阶段求值)

Constrains(约束条件):
• Constant expressions shall not contain assignment, increment, decrement, function-call, or comma operators, except when they are contained within a subexpression that is not evaluated.(我的理解：常量表达式不应该包含赋值，递增，递减，函数调用，逗号运算符。除非是包含在子表达式里:如 sizeof)
• Each constant expression shall evaluate to a constant that is in the range of representable values for its type.(每个常数表达式的计算值应在可表示的范围内其类型的值。)

## Declarations(声明)

Constrains(约束条件):
• A declaration shall declare at least a declarator (other than the parameters of a function or the members of a structure or union), a tag, or the members of an enumeration.

• If an identifier has no linkage, there shall be no more than one declaration of the identifier (in a declarator or type specifier) with the same scope and in the same name space, except for tags.(如果标识符没有链接，则标识符（在声明符或类型说明符中）的声明不得超过一个，且范围和名称空间相同，标记除外。)

• All declarations in the same scope that refer to the same object or function shall specify compatible types.

Semantics(语法):
• A declaration specifies the interpretation and attributes of a set of identifiers. A definition of an identifier is a declaration for that identifier that:

• for an object, causes storage to be reserved for that object;
• for a function, includes the function body;
• for an enumeration constant or typedef name, is the (only) declaration of the identifier.
• The declaration specifiers consist of a sequence of specifiers that indicate the linkage, storage duration, and part of the type of the entities that the declarators denote. The init-declarator-list is a comma-separated sequence of declarators, each of which may have additional type information, or an initializer, or both. The declarators contain the identifiers (if any) being declared.

• If an identifier for an object is declared with no linkage, the type for the object shall be complete by the end of its declarator, or by the end of its init-declarator if it has an initializer; in the case of function arguments (including in prototypes), it is the adjusted type (see 6.7.5.3) that is required to be complete

### Storage-class specifiers

Constrains(约束条件):

At most, one storage-class specifier may be given in the declaration specifiers in a declaration.(一个声明中的声明说明符最多只能提供一个存储类说明符)

### Type specifiers(类型说明符)

#### Structure and union specifiers(结构体和联合体说明符)

Constrains(约束条件):
1. A structure or union shall not contain a member with incomplete or function type (hence, a structure shall not contain an instance of itself, but may contain a pointer to an instance of itself), except that the last member of a structure with more than one named member may have incomplete array type; such a structure (and any union containing, possibly recursively, a member that is such a structure) shall not be a member of a structure or an element of an array.

2. The expression that specifies the width of a bit-field shall be an integer constant expression that has nonnegative value that shall not exceed the number of bits in an object of the type that is specified if the colon and expression are omitted. If the value is zero, the declaration shall have no declarator.

3. A bit-field shall have a type that is a qualified or unqualified version of _Bool, signed int, unsigned int, or some other implementation-defined type.

#### Enumeration specifiers(枚举说明符)

Constraints(约束条件):
The expression that defines the value of an enumeration constant shall be an integer
constant expression that has a value representable as an int.

### Type qualifiers

Constraints(约束条件):
Types other than pointer types derived from object or incomplete types shall not be restrict-qualified.