Preprocessor Directives
command | description |
---|---|
#define |
define a macro |
#include |
include a source code file |
#undef |
undefined macro |
#ifdef |
Returns true if the macro is defined |
#ifndef |
Returns true if the macro is not defined |
#if |
Compile the following code if the given condition is true |
#else |
Alternative to #if |
#elif |
If the #if condition is false, the current condition is true |
#endif |
End a #if...#else conditional compilation block |
#error |
Print an error message when standard error is encountered |
#pragma |
Issue special commands to the compiler using the standardized method |
// replace all MAX\_ARRAY\_LENGTH with 20
#define MAX\_ARRAY\_LENGTH 20
// Get stdio.h from the system library
#include <stdio.h>
// Get myheader.h in the local directory
#include "myheader.h"
#undef FILE\_SIZE
#define FILE\_SIZE 42 // undefine and define to 42
Comments