Skip to content

Defined

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

Home › Preprocessor › defined

defined

Preprocessor function to test if a symbol has been defined

Syntax

defined (symbol_name)

Parameters

  • symbol_name

Description

Given the symbol name, the defined() preprocessor function returns true if the symbol has been defined - or false if the symbol is unknown.

This is used mainly with #if (or #elseif).
Similar to #ifdef (or #elseifdef) except it allows more than one check to occur because of its flexibility.

Return Value

Returns non-zero (-1) if the symbol has been defined, otherwise returns zero (0).

Remarks

Differences from QB

  • New to FreeBASIC

See also

Examples

'e.g. - which symbols are defined out of a, b, c, and d ?

Const a = 300

#define b 12

Dim c As Single

#if defined(a)

 Print "a is defined"

#endif

#if defined(b)

 Print "b is defined"

#endif

#if defined(c)

 Print "c is defined"

#endif

#if defined(d)

 Print "d is defined"

#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