Preprocessor directives

Compiler instructions to be carried out before the actual compilation.

 

Always begins with a hash symbol #

 

Not terminated with a semi-colon ;

 

Used when compiling the program.

 

The most common preprocessor directives are: #include and #define

 

#define Defines a preprocessor macro
#include Substitues a preprocessor macro
#undef Undefines a macro
#ifdef Returns TRUE if macro is defined
#ifndef Returns TRUE if macro is not defined
#if Tests if a compile time condition is TRUE
#else the alternative for #if
#elif #else and #if in one statement
#endif Ends preprocessor conditional
#error Prints error message on stderr

Leave a Reply