Primary Expressions

The operands in expressions are called “primary expressions.”

Syntax

primary-expression :
identifier
constant
string-literal

( expression )

expression :
assignment-expression
expression
, assignment-expression

Identifiers

Identifiers can have integral, float, enum, struct, union, array, pointer, or function type. An identifier is a primary expression provided it has been declared as designating an object (in which case it is an l-value) or as a function (in which case it is a function designator). See the next section for a definition of l-value.

The pointer value represented by an array identifier is not a variable, so an array identifier cannot form the left-hand operand of an assignment operation and therefore is not a modifiable l-value.

An identifier declared as a function represents a pointer whose value is the address of the function. The pointer addresses a function returning a value of a specified type. Thus, function identifiers also cannot be l-values in assignment operations. See topic for more information about identifiers.

Constants

A constant operand has the value and type of the constant value it represents. A character constant has int type. An integer constant has int, long, unsigned int, or unsigned long type, depending on the integer's size and on the way the value is specified. See “Constants” for more information.

String Literals

A “string literal” is a character, wide character, or sequence of adjacent characters enclosed in double quotation marks. Since they are not variables, neither string literals nor any of their elements can be the left-hand operand in an assignment operation. The type of a string literal is an array of char (or an array of wchar_t for wide string literals. Arrays in expressions are converted to pointers. See “String Literals” for more information about strings.

Expressions in Parentheses

You can enclose any operand in parentheses without changing the type or value of the enclosed expression. For example, in the expression

( 10 + 5 ) / 5

the parentheses around 10 + 5 mean that the value of 10 + 5 is evaluated first and it becomes the left operand of the division (/) operator. The result of ( 10 + 5 ) / 5 is 3. Without the parentheses, 10 + 5 / 5 would evaluate to 11.

Although parentheses affect the way operands are grouped in an expression, they cannot guarantee a particular order of evaluation in all cases. For example, neither the parentheses nor the left-to-right grouping of the following expression guarantees what the value of i will be in either of the subexpressions:

( i++ +1 ) * ( 2 + i )

The compiler is free to evaluate the two sides of the multiplication in any order. If the initial value of i is zero, the whole expression could be evaluated as either of these two statements:

( 0 + 1 + 1 ) * ( 2 + 1 )

( 0 + 1 + 1 ) * ( 2 + 0 )

Exceptions resulting from side effects are discussed on topic .