Directive #elif


Directive #elif
Directive #elseif

#elif
#elseif

Description

These work as a combined #else and #if without adding an extra level of nesting.

Example

The following two are equivalent:

#ifdef A
    // Code for A.
  #else
  #ifdef B
    // Code for B.
  #else
  #ifdef C
    // Code for C.
  #else
    // Code for D.
  #endif
  #endif
  #endif

And

#ifdef A
    // Code for A.
  #elif defined(B)
    // Code for B.
  #elseif defined(C)
    // Code for C.
  #else
    // Code for D.
  #endif
See also

#if, #ifdef, #else, defined(), constant()