gcc __attribute__关键字举例之alias

来源:互联网 发布:佳能raw软件 编辑:程序博客网 时间:2024/04/29 11:04

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

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

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

test.cc

#include <stdio.h>extern "C" int __fun() {  printf("in %s\n",__FUNCTION__);  return 0;}int fun() __attribute__((alias("__fun")));int main(){  fun();  return 0;}编译运行:$g++ -o test test.cc ;./testin __fun


参考:

The alias function attribute

Function Attributes

原创粉丝点击