Symbol-Renaming Pragmas

6.59.7 Symbol-Renaming Pragmas

For compatibility with the Solaris system headers, GCC supports two #pragma directives that change the name used in assembly for a given declaration. 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 is defined if this pragma is available (currently on all platforms).

This pragma 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.

© Free Software Foundation
Licensed under the GNU Free Documentation License, Version 1.3.
https://gcc.gnu.org/onlinedocs/gcc-4.9.3/gcc/Symbol_002dRenaming-Pragmas.html

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部