ifndef directive

From Cppwiki

Jump to: navigation, search

#ifndef if a preprocessor directive. It allows for conditional compilaion if a given symbol has not been #defined.

The most common use of #ifndef is in include guards.

Example:

 #ifndef MYHEADER_H_JAN31_2007_
 #define MYHEADER_H_JAN31_2007_
 /* Header code goes here */
 #endif // #ifndef MYHEADER_H_JAN31_2007_

This example prevents the contents of the #ifndef block from being parsed more than once.

See also: #define, #endif, #if, #ifdef, #include

Personal tools