概述
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 __attribute__关键字举例之alias所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复