What are preprocessor operations in C programming

 ANSI C provides an operator # called stringizing operator to be used in the definition of macro functions. This operator converts a formal argument into a string. For example, if the macro is defined as follows:
and somewhere in the program the statement is written as: sum(a+b); then the preprocessor converts this line as shown below:

Token Pasting Operator ##

The token pasting operator ## defined by ANSI enables us to combine two tokens within a macro definition to form a single token.

#pragma  Directive

The #pragma directive is an implementation oriented directive that allows the user to specify various instructions to be given to the compiler. Syntax is as follows:
Where name is the name of the pragma we want. For example, under Microsoft C, #pragma loop_opt(on)  causes loop optimization to be performed.

#error  Directive

The #error directive is used to produce diagnostic messages during debugging. The general format is:
When the #error directive is encountered by the compiler, it displays the error message and terminates the program.
Example:

You are developing a program for selling in the open market. Some customers may insist on having certain additional features. However, you would like to have a single program that would satisfy both types of customers.
This situation is similar to the above situation and therefore the control directives take the following form:
Group-A lines are included if the customer ABC is defined. Otherwise, Group-B lines are included.

Situation 4

Suppose if you want to test a large program, you would like to include print calls in the program in certain places to display intermediate results and messages in order to trace the flow of execution and errors.
For this purpose we can use #if and #else directive as shown below:
Take your time to comment on this article.

Comments