Using #pragma preprocessor directive

#pragma preprocessor directive provides extra details to the compiler which is provided by C standard. These extra details can be anything which can not passed within the program. It provides additional information to the compiler. This directive is used by the compiler to offer some  features of machine or OS.

Syntax of #pragma preprocessor is given bellow;

// syntax of #pragmal preprocessor

// we can use any one of the following syntax
// we will use first syntax here in this article

#pragma token-string    // first syntax

__pragma(token-string)    // second syntax

The use of #pragma depends mostly on the compiler which you use. Here are some of the #pragma directive which can be used with Turbo C++ compiler.

pragma-preprocessor-directive-in-c-c-has-pragma-preprocessor-directive

C program using #pragma preprocessor directive

See the following program where we have used #pragma preprocessor directive for your better understanding about it.

// C program using #pragma

#include <stdio.h>
#include <conio.h>

void func();

#pragma startup func    // startup #pragma definition
#pragma exit func      // exit #pragma definition

void main(){
printf("I am learning #pragma preprocessor directive.\n");
getch();
}

void func(){
printf("competitiveprogrammer.com is best place for C.\n");
getch();
}

Output :

I am learning #pragma preprocessor directive.

Previous page#ifndef preprocessor directive

Next pageC enumeration