test.c: #include #include "test.h" void __attribute__((weak)) test(void){ printf("Hi\n"); } int main(void){ if(test) test(); return 0; } test2.c: #include "test.h" #include void test(void){ printf("Hi2\n"); } test.h: #ifndef __TEST_H__ #define __TEST_H__ void test(void); #endif