The preprocessor #pragma is basically used to change the execution order of the program that is a normal c/c++ program starts from main() and exits from main() but #pragma allows that to be changed.
the #pragma is divided as follows:-
#pragma startup < function name without brackets >:-
changes the start function that means this function will run before execution of main()
#include...
void fun1();
void fun2();
#pragma startup fun1
#pragma exit fun2
int main()
{
...
}
#pragma exit < function name without brackets >:-
changes the exit function that means this function will run after execution of main()
#include...
void fun1();
void fun2();
#pragma startup fun1
#pragma exit fun2
int main()
{
...
}
#pragma warn < -type of warning > :-
this directive tells the compiler whether or not we want to suppress a specific warning.
#include...
#pragma warn -rvl // return value
#pragma warn -par // parameter not used
#pragma warn -rch // unreachable code
void fun(int n)
{
...
//Do something
}
int main()
{
...
// Do something
fun(); // parameter not used warning suppressed.
}
There are many other pragma directives and you can easily find them just by doing an in-depth and proper search on google.