Page tree
Skip to end of metadata
Go to start of metadata

The #if compiler directive is used to test an expression for conditional compilation.

If the conditional expression is true, source lines following the #if directive are selected to be read by the compiler. Otherwise, lines are excluded until the next #elseif, #else, or #endif in the same #if group are reached.

The syntax is as follows:

#if defined(condition-name)

or

#if not defined(condition-name)


Example:

#if not defined(ranonce)
  // this code will only run one time 
  // even if this source file is included more than once with #include
  number = number + 1;
#endif
#define ranonce


RPG Equivalent:

/IF

  • No labels