summaryrefslogtreecommitdiff
path: root/devdocs/gcc~13/symbol-renaming-pragmas.html
blob: a66911e2ff1f0714d0af862b0f02af3ef20cf5f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
<div class="subsection-level-extent" id="Symbol-Renaming-Pragmas"> <div class="nav-panel"> <p> Next: <a href="structure-layout-pragmas" accesskey="n" rel="next">Structure-Layout Pragmas</a>, Previous: <a href="solaris-pragmas" accesskey="p" rel="prev">Solaris Pragmas</a>, Up: <a href="pragmas" accesskey="u" rel="up">Pragmas Accepted by GCC</a> [<a href="index#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="indices" title="Index" rel="index">Index</a>]</p> </div>  <h1 class="subsection" id="Symbol-Renaming-Pragmas-1"><span>6.62.9 Symbol-Renaming Pragmas<a class="copiable-link" href="#Symbol-Renaming-Pragmas-1"> ¶</a></span></h1> <p>GCC supports a <code class="code">#pragma</code> directive that changes the name used in assembly for a given declaration. While this pragma is supported on all platforms, it is intended primarily to provide compatibility with the Solaris system headers. This effect can also be achieved using the asm labels extension (see <a class="pxref" href="asm-labels">Controlling Names Used in Assembler Code</a>). </p> <dl class="table"> <dt>
<span><code class="code">redefine_extname <var class="var">oldname</var> <var class="var">newname</var></code><a class="copiable-link" href="#index-pragma_002c-redefine_005fextname"> ¶</a></span>
</dt> <dd> <p>This pragma gives the C function <var class="var">oldname</var> the assembly symbol <var class="var">newname</var>. The preprocessor macro <code class="code">__PRAGMA_REDEFINE_EXTNAME</code> is defined if this pragma is available (currently on all platforms). </p>
</dd> </dl> <p>This pragma and the <code class="code">asm</code> labels extension interact in a complicated manner. Here are some corner cases you may want to be aware of: </p> <ol class="enumerate"> <li> This pragma silently applies only to declarations with external linkage. The <code class="code">asm</code> label feature does not have this restriction. </li>
<li> In C++, this pragma silently applies only to declarations with “C” linkage. Again, <code class="code">asm</code> labels do not have this restriction. </li>
<li> If either of the ways of changing the assembly name of a declaration are 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. </li>
<li> The <var class="var">oldname</var> used by <code class="code">#pragma redefine_extname</code> is always the C-language name. </li>
</ol> </div><div class="_attribution">
  <p class="_attribution-p">
    &copy; Free Software Foundation<br>Licensed under the GNU Free Documentation License, Version 1.3.<br>
    <a href="https://gcc.gnu.org/onlinedocs/gcc-13.1.0/gcc/Symbol-Renaming-Pragmas.html" class="_attribution-link">https://gcc.gnu.org/onlinedocs/gcc-13.1.0/gcc/Symbol-Renaming-Pragmas.html</a>
  </p>
</div>