Whole document tree
    

Whole document tree

The C Preprocessor: Conditionals
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.5 Conditionals

In a macro processor, a conditional is a directive that allows a part of the program to be ignored during compilation, on some conditions. In the C preprocessor, a conditional can test either an arithmetic expression or whether a name is defined as a macro.

A conditional in the C preprocessor resembles in some ways an `if' statement in C, but it is important to understand the difference between them. The condition in an `if' statement is tested during the execution of your program. Its purpose is to allow your program to behave differently from run to run, depending on the data it is operating on. The condition in a preprocessing conditional directive is tested when your program is compiled. Its purpose is to allow different code to be included in the program depending on the situation at the time of compilation.

1.5.1 Why Conditionals are Used  What conditionals are for.
1.5.2 Syntax of Conditionals  How conditionals are written.
1.5.3 Keeping Deleted Code for Future Reference  Making code into a comment.
1.5.4 Conditionals and Macros  Why conditionals are used with macros.
1.5.5 Assertions  How and why to use assertions.
1.5.6 The `#error' and `#warning' Directives  Detecting inconsistent compilation parameters.



This document was generated by root on January, 30 2002 using texi2html