Skip to main content

#else

Specifies the beginning of the fall-through case in a set of preprocessor conditions.

Description

This macro preprocessor directive specifies the beginning of the fall-through case in a set of preprocessor conditions. It can follow #ifDef, #if, or #elseIf. It is followed by #endif. It has the form:

#else
  // subsequent indented lines for specified actions
#endif

The #else directive keyword should appear on a line by itself. Anything following #else on the same line is considered a comment and is not parsed.

For an example of #else with #if, see that directive; for an example with #endif, see that directive.

Note:

If #else appears in method code and has an argument other than a literal value of 0 or 1, the compiler generates code in subclasses (rather than invoking the method in the superclass). To avoid generating this code, test conditions for a value of 0 or 1, which results in simpler code and optimizes performance.

FeedbackOpens in a new tab