P99
|
◆ P99_INIT_FUNCTION_DECLARE
Request that FUNC is to be called at initialization time with priority NR.
The mechanism that ensures this feature is relatively fragile. You should in particular ensure that the compilation unit that contains p99_init_main (or This works by initializing a bunch of // ***** file module1.h
P99_DECLARE_ONCE_CHAIN(module1);
// always include this immediately before, even several times
#include "p99_init.h"
P99_INIT_FUNCTION_DECLARE(module1_trigger);
// ***** file module2.c
P99_DEFINE_ONCE_CHAIN(module1) {
// here initialize some global variables e.g
}
// always include this immediately before, even several times
#include "p99_init.h"
void module1_trigger(void) {
P99_INIT_CHAIN(module1);
}
// ***** file module2.h
P99_DECLARE_ONCE_CHAIN(module2);
// always include this immediately before, even several times
#include "p99_init.h"
P99_INIT_FUNCTION_DECLARE(module2_trigger);
// ***** file module2.c
// module2 depends upon module1 being properly initialized
P99_DEFINE_ONCE_CHAIN(module2, module1) {
// here initialize some global variables e.g
}
// always include this immediately before, even several times
#include "p99_init.h"
void module2_trigger(void) {
P99_INIT_CHAIN(module2);
}
Definition at line 143 of file p99_init.h. |