有不同的使用方法)。
代码a.c
1 #include
2
3 void bar()
4 {
5 printf("foo()\n");
6 }
代码b.c
复制代码
1 #include
2
3 static void foo() __attribute__((weakref("bar")));
4
5 int main(int argc, char** argv)
6 {
7 if (foo)
8 foo();
9
10 return 0;
11 }
复制代码
注意函数foo的static修饰符,没有的话会报错,这样将函数foo限制在只有本文件内可使用。