Pragma is used to turn on or off some of compiler/system features. Pragma's operation is system and compiler dependent. So, all pragmas may not work with all the compilers. When pragmas are encountered, the default behaviour of the compiler is overwritten by the options provided by pragmas. One of such pragma is
'pragma startup'
and 'pragma exit'
. The pragma startup
is used to specify function that will be called before main function and pragma exit
is used to specify function that would be called just before the program exits. Consider the example programPragma Example in C
- #include<stdio.h>
- void function1();
- void function2() ;
- #pragma startup function1
- #pragma exit function2
- void main()
- {
- printf("In main function");
- }
- void function1()
- {
- printf("In function1\n");
- }
- void function2()
- {
- printf("In function2");
- }
- Output:
- In function1
- In main function
- In function2 .
No comments:
Post a Comment