FANDOM


BYOND Environment This page contains an entry from the official DM Reference.

FormatEdit

#if Val
...
#elif Val2
...
#else
...
#endif

ArgsEdit

Val: A logical expression.

DescriptionEdit

The #if statement is used to conditionally compile code. If Val is true (non-zero), the code following the #if statement will be compiled. Otherwise, compilation skips to the next #elif, #else, or #endif statement.

defined() functionEdit

The function defined() can be used in the conditional expression. It is true if its argument is a defined macro (with #define) and false otherwise.

Example

#if defined(DEBUG)
// This code will be compiled if DEBUG is
// defined
#else
// This code will be compiled if DEBUG is
// not defined
#endif

See alsoEdit


preprocessor
directives #define | #error | #if | #ifdef | #ifndef | #include | #undef | #warn
macros DM_VERSION | __FILE__ | __LINE__ | __MAIN__
definitions DEBUG | FILE_DIR