Preprocessor Directive
Preprocessor Directive
A program that is invoked by the compiler to process code before compilation is known as preprocessor, commands for that program are known as directives, are lines of the source file beginning with the character #, which distinguishes them from lines of source program text. The effect of each preprocessor directive is a change in source code’s text and the result is a new source code file, which does not have any directives. The preprocessed source code (intermediate file) must be a valid C++ program, because it becomes the input to the compiler.
Preprocessor directives begin with the # token followed by a preprocessor keyword. The # token must appear as the first character which should not be white space on a line. The # is not part of the directive name and can be separated from the name with white spaces.
Preprocessor directives consist of the following:
- macro definitions (#define, #undef).
- Conditional inclusions (#ifdef, #ifndef, #if, #endif, #else and #elif).
- Line control (#line).
- Error directive (#error).
- Source file inclusion (#include).
- Pragma directive (#pragma).
Posted in Computer Science, Information Technology, Object Oriented Programming, Object Oriented Programming |
