What are some uses of #pragma in C, with examples?
#pragma startup is a directive which is used to call a function before the main function and to call another function after the main function, e.g.
#pragma startup func1
#pragma exit func2
Here, func1 runs before main and func2 runs afterwards.
NOTE: This code works only in Turbo-C compiler. To achieve this functionality in GCC, you can declare func1 and func2 like this:
void __attribute__((constructor)) func1();
void __attribute__((destructor)) func2();