Microchip Technology SW006023-2N Ficha De Dados

Página de 238
MPLAB
®
 XC32 C/C++ Compiler User’s Guide
DS51686E-page 120
 2012 Microchip Technology Inc.
8.5
CONDITIONAL OPERATOR OPERANDS
The middle operand in a conditional expression may be omitted. Then if the first 
operand is nonzero, its value is the value of the conditional expression. This is a 
non-standard extension to the language. Using this feature reduces your code 
portability.
Therefore, the expression:
x ? : y
has the value of x if that is nonzero; otherwise, the value of y. 
This example is perfectly equivalent to:
x ? x : y
In this simple case, the ability to omit the middle operand is not especially useful. When 
it becomes useful is when the first operand does, or may (if it is a macro argument), 
contain a side effect. Then repeating the operand in the middle would perform the side 
effect twice. Omitting the middle operand uses the value already computed without the 
undesirable effects of recomputing it.
8.6
CASE RANGES
You can specify a range of consecutive values in a single case label, like this:
case low ... high:
This has the same effect as the proper number of individual case labels, one for each 
integer value from low to high, inclusive. This is a non-standard extension to the lan-
guage. Using this feature reduces your code portability.
This feature is especially useful for ranges of ASCII character codes:
case 'A' ... 'Z':
Be careful: Write spaces around the ..., otherwise it may be parsed incorrectly when 
you use it with integer values. For example, write this:
case 1 ... 5:
rather than this: 
case 1...5: