利用gcc区分strong/weak symbol的机制实现

weak.c:
attribute((weak)) void foo(void)
{
printf("i'm weak\n");
}

strong.c:
void foo(void)
{
printf("i'm strong\n");
}

main.c:
int main(int argc, char **argv)
{
foo();
}

运行后会打印i'm strong.
反之,将strong.c中的foo添加attribute weak,去掉weak.c中的attribute,运行打印i'm weak.

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-27
  • 2021-12-18
  • 2021-12-18
  • 2021-05-15
  • 2021-12-15
  • 2021-11-30
猜你喜欢
  • 2021-10-11
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-11
  • 2022-12-23
相关资源
相似解决方案