1 #include <stdio.h> 2 int global_var = 84; 3 4 static int stat_var = 84; 5 test_static_var()6void test_static_var() 7 { 8 stat_var++; 9 } 10 test_global_var()11void test_global_var() 12 { 13 global_var++; 14 } 15 ret_static()16int ret_static() 17 { 18 return stat_var; 19 } 20 ret_global()21int ret_global() 22 { 23 return global_var; 24 } before_main()25__attribute__((constructor)) void before_main() 26 { 27 printf("before main\n"); 28 } 29 after_main()30__attribute__((destructor)) void after_main() 31 { 32 printf("after main\n"); 33 } 34