|
|
The clause #if clause is rarely used....
I will skip it.
Syntax | Meaning |
---|---|
#ifdef MACRO-NAME text segment #endif |
|
#ifdef MACRO-NAME text segment 1 #else text segment 2 #endif |
|
#ifdef MACRO-NAME-1 text segment 1 #elif MACRO-NAME-2 text segment 2 [#else text segment 3] #endif |
|
#define DEBUG (This defines DEBUG to be the empty string !) int main( ) { int x, y; x = 3; y = 4; #ifdef DEBUG printf("x = %d\n", x); // Print variable x for debugging printf("y = %d\n", y); // Print variable x for debugging #endif } |
Output of the C pre-processor:
int main( ) { int x, y; x = 3; y = 4; printf("x = %d\n", x); printf("y = %d\n", y); } |
How to run the program:
|
|
gcc -Dmacro[=defn] ...... |
|
How to run the program:
|
|