1<html lang="en"> 2<head> 3<title>Symbol-Renaming Pragmas - Using the GNU Compiler Collection (GCC)</title> 4<meta http-equiv="Content-Type" content="text/html"> 5<meta name="description" content="Using the GNU Compiler Collection (GCC)"> 6<meta name="generator" content="makeinfo 4.13"> 7<link title="Top" rel="start" href="index.html#Top"> 8<link rel="up" href="Pragmas.html#Pragmas" title="Pragmas"> 9<link rel="prev" href="Solaris-Pragmas.html#Solaris-Pragmas" title="Solaris Pragmas"> 10<link rel="next" href="Structure_002dPacking-Pragmas.html#Structure_002dPacking-Pragmas" title="Structure-Packing Pragmas"> 11<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> 12<!-- 13Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 141998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 152010 Free Software Foundation, Inc. 16 17Permission is granted to copy, distribute and/or modify this document 18under the terms of the GNU Free Documentation License, Version 1.3 or 19any later version published by the Free Software Foundation; with the 20Invariant Sections being ``Funding Free Software'', the Front-Cover 21Texts being (a) (see below), and with the Back-Cover Texts being (b) 22(see below). A copy of the license is included in the section entitled 23``GNU Free Documentation License''. 24 25(a) The FSF's Front-Cover Text is: 26 27 A GNU Manual 28 29(b) The FSF's Back-Cover Text is: 30 31 You have freedom to copy and modify this GNU Manual, like GNU 32 software. Copies published by the Free Software Foundation raise 33 funds for GNU development.--> 34<meta http-equiv="Content-Style-Type" content="text/css"> 35<style type="text/css"><!-- 36 pre.display { font-family:inherit } 37 pre.format { font-family:inherit } 38 pre.smalldisplay { font-family:inherit; font-size:smaller } 39 pre.smallformat { font-family:inherit; font-size:smaller } 40 pre.smallexample { font-size:smaller } 41 pre.smalllisp { font-size:smaller } 42 span.sc { font-variant:small-caps } 43 span.roman { font-family:serif; font-weight:normal; } 44 span.sansserif { font-family:sans-serif; font-weight:normal; } 45--></style> 46<link rel="stylesheet" type="text/css" href="../cs.css"> 47</head> 48<body> 49<div class="node"> 50<a name="Symbol-Renaming-Pragmas"></a> 51<a name="Symbol_002dRenaming-Pragmas"></a> 52<p> 53Next: <a rel="next" accesskey="n" href="Structure_002dPacking-Pragmas.html#Structure_002dPacking-Pragmas">Structure-Packing Pragmas</a>, 54Previous: <a rel="previous" accesskey="p" href="Solaris-Pragmas.html#Solaris-Pragmas">Solaris Pragmas</a>, 55Up: <a rel="up" accesskey="u" href="Pragmas.html#Pragmas">Pragmas</a> 56<hr> 57</div> 58 59<h4 class="subsection">6.56.7 Symbol-Renaming Pragmas</h4> 60 61<p>For compatibility with the Solaris and Tru64 UNIX system headers, GCC 62supports two <code>#pragma</code> directives which change the name used in 63assembly for a given declaration. <code>#pragma extern_prefix</code> is only 64available on platforms whose system headers need it. To get this effect 65on all platforms supported by GCC, use the asm labels extension (see <a href="Asm-Labels.html#Asm-Labels">Asm Labels</a>). 66 67 <dl> 68<dt><code>redefine_extname </code><var>oldname</var> <var>newname</var><dd><a name="index-pragma_002c-redefine_005fextname-3232"></a> 69This pragma gives the C function <var>oldname</var> the assembly symbol 70<var>newname</var>. The preprocessor macro <code>__PRAGMA_REDEFINE_EXTNAME</code> 71will be defined if this pragma is available (currently on all platforms). 72 73 <br><dt><code>extern_prefix </code><var>string</var><dd><a name="index-pragma_002c-extern_005fprefix-3233"></a> 74This pragma causes all subsequent external function and variable 75declarations to have <var>string</var> prepended to their assembly symbols. 76This effect may be terminated with another <code>extern_prefix</code> pragma 77whose argument is an empty string. The preprocessor macro 78<code>__PRAGMA_EXTERN_PREFIX</code> will be defined if this pragma is 79available (currently only on Tru64 UNIX). 80</dl> 81 82 <p>These pragmas and the asm labels extension interact in a complicated 83manner. Here are some corner cases you may want to be aware of. 84 85 <ol type=1 start=1> 86<li>Both pragmas silently apply only to declarations with external 87linkage. Asm labels do not have this restriction. 88 89 <li>In C++, both pragmas silently apply only to declarations with 90“C” linkage. Again, asm labels do not have this restriction. 91 92 <li>If any of the three ways of changing the assembly name of a 93declaration is applied to a declaration whose assembly name has 94already been determined (either by a previous use of one of these 95features, or because the compiler needed the assembly name in order to 96generate code), and the new name is different, a warning issues and 97the name does not change. 98 99 <li>The <var>oldname</var> used by <code>#pragma redefine_extname</code> is 100always the C-language name. 101 102 <li>If <code>#pragma extern_prefix</code> is in effect, and a declaration 103occurs with an asm label attached, the prefix is silently ignored for 104that declaration. 105 106 <li>If <code>#pragma extern_prefix</code> and <code>#pragma redefine_extname</code> 107apply to the same declaration, whichever triggered first wins, and a 108warning issues if they contradict each other. (We would like to have 109<code>#pragma redefine_extname</code> always win, for consistency with asm 110labels, but if <code>#pragma extern_prefix</code> triggers first we have no 111way of knowing that that happened.) 112 </ol> 113 114 </body></html> 115 116