All for Joomla All for Webmasters

C #pragma

The #pragma preprocessor directive is used to provide additional information to the compiler. The #pragma directive is used by the compiler to offer machine or operating-system feature.

Syntax:

  1. #pragma token

Different compilers can provide different usage of #pragma directive.

The turbo C++ compiler supports following #pragma directives.

  1. #pragma argsused
  2. #pragma exit
  3. #pragma hdrfile
  4. #pragma hdrstop
  5. #pragma inline
  6. #pragma option
  7. #pragma saveregs
  8. #pragma startup
  9. #pragma warn

Let’s see a simple example to use #pragma preprocessor directive.

  1. #include<stdio.h>
  2. #include<conio.h>
  3. void func() ;
  4. #pragma startup func
  5. #pragma exit func
  6. void main(){
  7. printf(“\nI am in main”);
  8. getch();
  9. }
  10. void func(){
  11. printf(“\nI am in func”);
  12. getch();
  13. }

Output:

I am in func
I am in main
I am in func
PinIt
submit to reddit

Leave a Reply

Top