#ifndef...#endif

Provides conditional compiling capabilities.

Syntax
#ifndef identifier ... Source code for conditional compile
[#else] ... Source code for true condition
#endif

Parameters

Identifier
Keyword defined by the user which when not defined allows the source code defined between #ifndef and #else or #endif to be compiled. Thus the identifier acts as the condition for the conditional compile.

Description
This instruction is called the "if not defined" instruction. #ifndef...#else...#endif allow for the conditional compiling of selected source code. #The #else statement is optional.

If defined, and the #else statement is not used, the statements between #ifndef and #endif are not compiled. #Otherwise, if #else is used, then the statements between #else and #endif are compiled.

If not defined, and the #else statement is not used, the statements between #ifndef and #endif are compiled. #Otherwise, if #else is used, then the statements between #else and #endif are not compiled.

Note


  • #Difference between #ifdef and #ifndef

    #The fundamental difference between #ifdef and #ifndef is that the #ifdef instruction compiles the specified source code if the identifier is defined. The #ifndef instruction compiles the specified source code if the identifier is not defined.


See Also
​#define, #ifdef

#ifndef Example
A section of code from a sample program using #ifndef is shown below. In the example below, the printing of the value of the variable A$ will be executed depending on the presence or absence of the definition of the #define NODELAY pseudo instruction. If the #define NODELAY pseudo instruction was used earlier in this source, the Wait 1 line will NOT be compiled along with the rest of the source for this program when it is compiled. If the #define NODELAY pseudo instruction was not used (i.e. NODELAY is not defined) earlier in this source, the Wait 1 line will be compiled and later executed when the program is run. The printing of the string "The End" will occur regardless of the #define NODELAY pseudo instruction.

' Comment out next line to force delays.
 #define NODELAY 1

Input #1, A$
 #ifndef NODELAY
    Wait 1
 #endif
Print "The End"