Next: , Previous: Solaris Pragmas, Up: Pragmas


5.52.6 Symbol-Renaming Pragmas

For compatibility with the Solaris and Tru64 UNIX system headers, GCC supports two #pragma directives which change the name used in assembly for a given declaration. These pragmas are only available on platforms whose system headers need them. To get this effect on all platforms supported by GCC, use the asm labels extension (see Asm Labels).

redefine_extname oldname newname
This pragma gives the C function oldname the assembly symbol newname. The preprocessor macro __PRAGMA_REDEFINE_EXTNAME will be defined if this pragma is available (currently only on Solaris).
extern_prefix string
This pragma causes all subsequent external function and variable declarations to have string prepended to their assembly symbols. This effect may be terminated with another extern_prefix pragma whose argument is an empty string. The preprocessor macro __PRAGMA_EXTERN_PREFIX will be defined if this pragma is available (currently only on Tru64 UNIX).

These pragmas and the asm labels extension interact in a complicated manner. Here are some corner cases you may want to be aware of.

  1. Both pragmas silently apply only to declarations with external linkage. Asm labels do not have this restriction.
  2. In C++, both pragmas silently apply only to declarations with “C” linkage. Again, asm labels do not have this restriction.
  3. If any of the three ways of changing the assembly name of a declaration is applied to a declaration whose assembly name has already been determined (either by a previous use of one of these features, or because the compiler needed the assembly name in order to generate code), and the new name is different, a warning issues and the name does not change.
  4. The oldname used by #pragma redefine_extname is always the C-language name.
  5. If #pragma extern_prefix is in effect, and a declaration occurs with an asm label attached, the prefix is silently ignored for that declaration.
  6. If #pragma extern_prefix and #pragma redefine_extname apply to the same declaration, whichever triggered first wins, and a warning issues if they contradict each other. (We would like to have #pragma redefine_extname always win, for consistency with asm labels, but if #pragma extern_prefix triggers first we have no way of knowing that that happened.)