ABL electronic PIC12 Personal Computer User Manual


 
Binary operator comma (,) has the lowest precedence and associates from left to
right, so that
a, b, c is same as (a, b), c. This allows us to write sequences
with any number of expressions:
expression_1
,
expression_2
, ...
expression_n
;
this results in the left-to-right evaluation of each expression, with the value and
type of
expression_n giving the result of the whole expression. Results of other
expressions are discarded, but their (possible) side-effect do occur.
For example:
result = (a = 5, b /= 2, c++);
/* returns preincremented value of variable c, but also
intializes a, divides b by 2, and increments c */
result = (x = 10, y = x + 3, x--, z -= x * 3 - --y);
/* returns computed value of variable z,
and also computes x and y */
Note
Do not confuse comma operator (sequence operator) with the comma punctuator
which separates elements in a function argument list and initializator lists. Mixing
the two uses of comma is legal, but you must use parentheses to distinguish them.
To avoid ambiguity with the commas in function argument and initializer lists, use
parentheses. For example,
func(i, (j = 1, j + 4), k);
calls function func with three arguments (i, 5, k), not four.
mikroC
- C Compiler for Microchip PIC microcontrollers
mikroC
making it simple...
11 4
MikroElektronika:
Development
tools
-
Books
-
Compilers
page