C Preprocessor Conditional Compilation Directives

  • In C Preprocessor Conditional Compilation Directives, depends on the condition block name to be pass from compilation process or not which is decided that the time of preprocessing.
  • If the condition is true, then block will be passed from compilation process. If condition is false then complete block of the statements will be removed from the source at the time of preprocessor.

Example:

void main()
{
printf(“K”);
printf(“Welcome “);
#if 5>8
printf(“2”);
printf(“Hello”);
#endif
printf(“to K2schools”);
}


Outout:
K Welcome to K2schools

  • In the above program at the time of preprocessing condition became false so automatically correspondent block will be removed from the source and it pass to compilation.
  • By using conditional compilation preprocessor we can reduce the size of exe file because at the time of preprocessing by removing the statements it reduce obj file size then automatically exe file size reduced
  • .

Powered by k2schools