我是靠谱客的博主 动人毛巾,这篇文章主要介绍gcc __attribute__关键字举例之alias,现在分享给大家,希望可以做个参考。

GCC使用__attribute__关键字来描述函数,变量和数据类型的属性,用于编译器对源代码的优化。

alias属性用于设置一个函数的别名。

以下程序为C++版本,C版本去掉extern "C"即可

test.cc

#include <stdio.h>
extern "C" int __fun() 
{
  printf("in %sn",__FUNCTION__);
  return 0;
}

int fun() __attribute__((alias("__fun")));
int main()
{
  fun();
  return 0;
}
编译运行:
$g++ -o test test.cc ;./test
in __fun


参考:

The alias function attribute

Function Attributes

最后

以上就是动人毛巾最近收集整理的关于gcc __attribute__关键字举例之alias的全部内容,更多相关gcc内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(67)

评论列表共有 0 条评论

立即
投稿
返回
顶部