C #pragma preprocessor directive
This is an implementation defined directive that allows various instructions to be given to the compiler
Let us see syntax
#pragma name
Here name is the name of pragma. The pragma so the pragma may be different for different compilers. so we should check our compiler’s manual for the pragmas available and their details. Any unrecogniged pragma directive is just ignore, without showing any warning or error
#pragma startup and #pragma exit: These directives very helpful to specify the functions to run before program startup( before the main() function) and just before program exit (Terminate)(just before the control returns from main()). This directive is a special directive and also used for turn on or off some features. This type of directives are compiler dependent i.e., it may be very from compiler to compiler.
Look at the below program:
Below program will not work with GCC compilers
void func0();
void func1();
#pragma startup func0
#pragma exit func1
void func0()
{
printf("Inside func0()\n");
}
void func1()
{
printf("Inside func1()\n");
}
int main()
{
printf("Inside main()\n");
return 0;
}
|