The #ifdef and #ifndef Directives

The #ifdef and #ifndef directives perform the same task as the #if directive when it is used with defined(identifier).

Syntax

if-group :
#ifdef identifier new-line group opt
#ifndef identifier new-line group opt

the syntax above is equivalent to

#if defined identifier #if !defined identifier

You can use the #ifdef and #ifndef directives anywhere #if can be used. The #ifdef identifier statement is equivalent to #if 1 when identifier has been defined and is equivalent to #if 0 when identifier has not been defined, has been undefined with the #undef directive, or has been defined with the value zero. These directives check only for identifiers defined with #define (or #undefined), not for identifiers declared in the C source code.

The #ifdef and #ifndef directives are provided mainly for compatibility with previous versions of the compiler. The preferred form is an #if directive and a defined identifier constant expression since more complex expressions can be used with #if defined.