gcc __attribute__キーワードの例alias

521 ワード

GCC使用_attribute__キーワードは、コンパイラによるソースコードの最適化に使用される関数、変数、およびデータ型のプロパティを記述します.
aliasプロパティは、関数の別名を設定するために使用されます.
以下のプログラムはC++バージョンで、Cバージョンはextern“C”を削除すればいいです
test.cc
#include 
extern "C" int __fun() 
{
  printf("in %s
",__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