cpp: Elif

1 
1 4.2.5 Elif
1 ----------
1 
1 One common case of nested conditionals is used to check for more than
1 two possible alternatives.  For example, you might have
1 
1      #if X == 1
1      ...
1      #else /* X != 1 */
1      #if X == 2
1      ...
1      #else /* X != 2 */
1      ...
1      #endif /* X != 2 */
1      #endif /* X != 1 */
1 
1    Another conditional directive, '#elif', allows this to be abbreviated
1 as follows:
1 
1      #if X == 1
1      ...
1      #elif X == 2
1      ...
1      #else /* X != 2 and X != 1*/
1      ...
1      #endif /* X != 2 and X != 1*/
1 
1    '#elif' stands for "else if".  Like '#else', it goes in the middle of
1 a conditional group and subdivides it; it does not require a matching
1 '#endif' of its own.  Like '#if', the '#elif' directive includes an
1 expression to be tested.  The text following the '#elif' is processed
1 only if the original '#if'-condition failed and the '#elif' condition
1 succeeds.
1 
1    More than one '#elif' can go in the same conditional group.  Then the
1 text after each '#elif' is processed only if the '#elif' condition
1 succeeds after the original '#if' and all previous '#elif' directives
1 within it have failed.
1 
1    '#else' is allowed after any number of '#elif' directives, but
1 '#elif' may not follow '#else'.
1