alias (IBM extension)

The alias function attribute causes the function declaration to appear in the object file as an alias for another symbol. This language feature provides a technique for coping with duplicate or cumbersome names.

Read syntax diagramSkip visual syntax diagram
alias function attribute syntax

>>-__attribute__------------------------------------------------>

>--((--+-alias-----+--(--"original_function_name"--)--))-------><
       '-__alias__-'                                       

C only begins The aliased function can be defined after the specification of its alias with this function attribute. C also allows an alias specification in the absence of a definition of the aliased function in the same compilation unit.

The following code declares func1 to be an alias for __func2:
void __func2(){   /*  function body  */   }
void func1() __attribute__((alias("__func2")));
C only ends

C++ only begins The original_function_name must be the mangled name.

The following code declares func1 to be an alias for __func2
extern "C" __func2(){   /*  function body  */   }
void func1() __attribute__((alias("__func2")));
C++ only ends

The compiler does not check for consistency between the declaration of func1 and definition of __func2. Such consistency remains the responsibility of the programmer.