MISCELLANEOUS DIRECTIVES OF C PREPROCESSOR

MISCELLANEOUS DIRECTIVES OF C PREPROCESSOR

In the previous article we’ve studied about types of c preprocessor . In this article we will discuss concerning it further MISCELLANEOUS DIRECTIVES OF C PREPROCESSOR. MISCELLANEOUS DIRECTIVES OF C PREPROCESSOR. Are types of C preprocessor. In this article we’ll study more about it.

MISCELLANEOUS DIRECTIVES:

There are two more preprocessor directives are available. Though they are not commonly use. They are:

  • #undef
  • #pragma
#undef directives:

On some occasion. It may be desirable to cause a defined name to become ‘undefined’. Then This can be accomplish by means of #undef directives. In order to undefine the statement. That has #define earlier. The statement : #undef macro template. For example: #undef PENTIUM. This would cause the definition PENTIUM to be removed from system. All subsequent #ifdef PENTIUM statements would evaluated to false.

#pragma directives:

This is another special purpose directive. It can be use to turn off certain features . Pragma varies from one compiler to another. some of them are:

a) #pragma startup or #pragma exit. These directive allow us to specify functions. That are called upon program startup. Or program exit.

b) #pragma warn: On compilation. Compiler reports errors. Also warnings in the program, If any. Further, Errors provide the programmers with no option. Apart from correcting them. Warnings on the other hand. Offer the programmer. A hint or suggestion. That something is wrong. With a particular piece of code. In conclusion, Two most common situation where warnings are displayed:

  • 1). Firstly . If we have written code . That the compiler designer considers bad programming. For example : If a function returns nothing. That means it does not return any value. Then it must declare as void. Otherwise also warning will display.
  • 2). If you have written code . That might cause run time errors . For example assigning a value to an uninitialized pointer. Then the warning will display.

The pragma warn tells compiler. whether or not. We want to suppress that particular warning.

for example: #pragma warn – RVL /* returns value*/. #pragma warn- Par /*parameters not used*/. #pragma warn- RCH /* unreachable code*/