Name

#ifdef and #ifndef

Synopsis

The #ifdef and #ifndef directives can be used to make program text directly conditional upon whether a given macro name is defined.

Syntax:

#ifdef name
#ifndef name

The #ifdef directive is “true” if name is defined, and the #ifndef directive is “true” if name is not defined. Both require a closing #endif directive.

The following two constructions are equivalent:

#ifdef VERSION
  ...
#endif
#if defined(VERSION
  ...
#endif

Get C Pocket Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.