A Complete Guide to Programming in C++ part 82. This book provides both novice and experienced programmers with a comprehensive resource manual for the C++ programming language. Readers gain experience in all aspects of programming, from elementary language concepts to professional software development, with in depth coverage of all the language elements en route. These elements are carefully ordered to help the reader create useful programs every step of the way. | PREPROCESSOR DIRECTIVES Example include iostream include if VERSION 1 define MYPROJ_H else define MYPROJ_H endif include MYPROJ_H The if elif else and endif Directives You can use the if elif and endif directives to compile certain parts of a source file and ignore others. The directives are known as conditional compilation directives for this reason. Syntax if expressionl textl elif expression2 text2 elif expression n text n else text n 1 endif Each if directive must be terminated by an endif directive. Multiple elif directives can occur in between. The else directive can occur once only. The preprocessor evaluates expressionl expression2 . in sequence. If an expression that yields true is found that is its value is not 0 the corresponding code for this expression is processed. If none of these expressions is true the else directive is executed. If this directive is omitted no corresponding code is processed. expressionl expressionl . must be constant expressions of integral types and cannot contain the cast operator. Some compilers do not allow the use of the sizeof operator. The corresponding text is a source text that is it comprises preprocessor directives C statements or whole C programs. When a corresponding text is processed the preprocessor may first execute directives before passing the expanded source code to the compiler for compilation. Code that the preprocessor has not processed is removed from the source. 790 APPENDIX The defined Operator You can use the defined operator to check whether a symbolic constant or macro has been defined. Syntax defined name The operator returns a value other than 0 if valid definition for name exists and the value 0 in all other cases. A definition created using the define directive remains valid until it is removed by an undef directive. If the substitute text following name in the define directive is missing the definition is still valid. The defined operator is normally used in if or .