How to execute a function on startup before main() function ?

Use #pragma startup and #pragma exit preprocessor directives to specify a function which executes upon program startup before main( ) is called or program exits ( just before the program terminates). The syntax is as follows:

#pragma startup func_name <priority>

#pragma exit func_name <priority>

The declaration of the function should be as follows:

void func ( void ) ;

priority variable is optional. It is an integer in the range 64 to 255. ( 0-63 are used by C libraries). Highest priority is 0. The functions with higher priorities are called first at startup and last at exit. If priority is not specified, it defaults to 100.

Subscribe / Share

It's very calm over here, why not leave a comment?

Leave a Reply




Categories

Powered by Yahoo! Answers