C Tutorial #if
main()
Multiple Files
Prototypes
Preprocessor
#define
#include
foo.h vs foo.c
#if

Multiple #includes -- #pragma once
Assert 
 
 

 

HOME
 

At compile time,  there is some space of names defined by the #defines. The #if test can

be used at compile-time to look at those symbols and turn on and off which lines the

compiler uses. The following example depends on the value of the FOO #define symbol.

If it is true, then the "aaa" lines (whatever they are)  are compiled, and the "bbb" lines are

ignored. If FOO were 0, then the reverse would be true.

 

#define FOO 1

 

...

 

#if FOO aaa aaa

#else bbb bbb

#endif

 

You can use #if 0 ...#endif to effectively comment out areas of code you don't want to compile, but which you want to keeep in the source file.

Want To Know more with

Video ???

Contact for more learning: webmaster@freehost7com