Skip to content
Paul Squires edited this page Sep 19, 2026 · 1 revision

Home › Preprocessor › #if

#if

Preprocessor conditional directive

Syntax

#if (expression)
' Conditionally included statements
#endif

Description

Conditionally includes statements at compile time.

Statements contained within the #if / #endif block are included if expression evaluates to True (non-zero) and excluded (ignored) if expression evaluates to False (0).

This conditional directive differs from the If conditional statement in that #if is evaluated at compile-time and If is evaluated at run-time.

Remarks

Differences from QB

  • New to FreeBASIC

See also

Examples

#define DEBUG_LEVEL 1

#if (DEBUG_LEVEL >= 2)

  ' This line is not compiled since the expression is False

  Print "Starting application"

#endif

Category: Preprocessor
Kind: keyword


Reproduced from the FreeBASIC Wiki Manual under the GNU Free Documentation License 1.3 — with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. Copyright © the FreeBASIC project and wiki contributors. See License.

Clone this wiki locally