__attribute__((constructor)) 先于main()函数调用
__attribute__((destructor))在main()函数后调用
#include <stdio.h>
#include <stdlib.h>
static void before(void) __attribute__((constructor));
static void after(void) __attribute__((destructor));
static void before() {
printf("before main\n");
}
static void after(void) {
printf("after main\n");
}
int main() {
printf("main\n");
return 0;
}