a.c (466B)
1 /* INIT_ARRAY priority ordering: lower priority number runs first. 2 * a.c registers priority 101 (runs first), b.c registers 102 (runs second). 3 * test_main verifies the sequence buffer matches [1, 2]. */ 4 static int g_seq[2]; 5 static int g_pos = 0; 6 7 void record_seq(int v) { 8 if (g_pos < 2) g_seq[g_pos++] = v; 9 } 10 11 static void __attribute__((constructor(101))) init_a(void) { record_seq(1); } 12 13 int test_main(void) { return (g_seq[0] == 1 && g_seq[1] == 2) ? 0 : 1; }