C++ Preprocessor
Preprocessor directives are one of the unique features of C++. It provides many tools that other high-level language does not, and programmers can use these tools to create efficient, easy-to-read, easy-to-modify and portable C ++ programs.
Before a C++ program gets compiled by the compiler, the source-code gets processed by the compiler. This technique is called preprocessor and the process is called preprocessing. It is separate program part that the C++ compiler invokes it at the first part of the translation. This technique is not a part of the compiler but it is a separate method that comes under compilation process. It directs the compiler that the information should be preprocessed before the actual compilation starts.
All preprocessor directives in C++ begin with #, and they do not need to end with a semicolon(;) because this is not a statement in C++.
The #define directive creates a symbolic constants and these symbolic constants are called macro.
The general form of the directive is:
Syntax:
#define macro-name replacement-text
Simple Program of Preprocessor Directive
Example:
#include<iostream>
#define val 12
using namespace std;
int main()
{
cout << "Value is :" << val << endl;
}
There are different preprocessor directives that perform different tasks. You can categorize these Preprocessor Directives as follows:
Comments
Post a Comment