RAD Studio |  |

#ifdef And #ifndef

Syntax

Copy Code

    #ifdef identifier
    #ifndef identifier

Description

The #ifdef and #ifndef conditional directives let you test whether an identifier is currently defined or not; that is, whether a previous #define command has been processed for that identifier and is still in force. The line

Copy Code

    #ifdef identifier

has exactly the same effect as

Copy Code

    #if 1

if identifier is currently defined, and the same effect as

Copy Code

    #if 0

if identifier is currently undefined.

#ifndef tests true for the "not-defined" condition, so the line

Copy Code

    #ifndef identifier

has exactly the same effect as

Copy Code

    #if 0

if identifier is currently defined, and the same effect as

Copy Code

    #if 1

if identifier is currently undefined.

The syntax thereafter follows that of the #if, #elif, #else, and #endif.

An identifier defined as NULL is considered to be defined.

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!