Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

236 Zeilen
11KB

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Copyright (C) 1988-2020 Free Software Foundation, Inc.
  4. Permission is granted to copy, distribute and/or modify this document
  5. under the terms of the GNU Free Documentation License, Version 1.3 or
  6. any later version published by the Free Software Foundation; with the
  7. Invariant Sections being "Funding Free Software", the Front-Cover
  8. Texts being (a) (see below), and with the Back-Cover Texts being (b)
  9. (see below). A copy of the license is included in the section entitled
  10. "GNU Free Documentation License".
  11. (a) The FSF's Front-Cover Text is:
  12. A GNU Manual
  13. (b) The FSF's Back-Cover Text is:
  14. You have freedom to copy and modify this GNU Manual, like GNU
  15. software. Copies published by the Free Software Foundation raise
  16. funds for GNU development. -->
  17. <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
  18. <head>
  19. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  20. <title>Compatibility (Using the GNU Compiler Collection (GCC))</title>
  21. <meta name="description" content="Compatibility (Using the GNU Compiler Collection (GCC))">
  22. <meta name="keywords" content="Compatibility (Using the GNU Compiler Collection (GCC))">
  23. <meta name="resource-type" content="document">
  24. <meta name="distribution" content="global">
  25. <meta name="Generator" content="makeinfo">
  26. <link href="index.html#Top" rel="start" title="Top">
  27. <link href="Option-Index.html#Option-Index" rel="index" title="Option Index">
  28. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  29. <link href="index.html#Top" rel="up" title="Top">
  30. <link href="Gcov.html#Gcov" rel="next" title="Gcov">
  31. <link href="Forwarding-hook.html#Forwarding-hook" rel="prev" title="Forwarding hook">
  32. <style type="text/css">
  33. <!--
  34. a.summary-letter {text-decoration: none}
  35. blockquote.indentedblock {margin-right: 0em}
  36. blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
  37. blockquote.smallquotation {font-size: smaller}
  38. div.display {margin-left: 3.2em}
  39. div.example {margin-left: 3.2em}
  40. div.lisp {margin-left: 3.2em}
  41. div.smalldisplay {margin-left: 3.2em}
  42. div.smallexample {margin-left: 3.2em}
  43. div.smalllisp {margin-left: 3.2em}
  44. kbd {font-style: oblique}
  45. pre.display {font-family: inherit}
  46. pre.format {font-family: inherit}
  47. pre.menu-comment {font-family: serif}
  48. pre.menu-preformatted {font-family: serif}
  49. pre.smalldisplay {font-family: inherit; font-size: smaller}
  50. pre.smallexample {font-size: smaller}
  51. pre.smallformat {font-family: inherit; font-size: smaller}
  52. pre.smalllisp {font-size: smaller}
  53. span.nolinebreak {white-space: nowrap}
  54. span.roman {font-family: initial; font-weight: normal}
  55. span.sansserif {font-family: sans-serif; font-weight: normal}
  56. ul.no-bullet {list-style: none}
  57. -->
  58. </style>
  59. </head>
  60. <body lang="en">
  61. <a name="Compatibility"></a>
  62. <div class="header">
  63. <p>
  64. Next: <a href="Gcov.html#Gcov" accesskey="n" rel="next">Gcov</a>, Previous: <a href="Objective_002dC.html#Objective_002dC" accesskey="p" rel="prev">Objective-C</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
  65. </div>
  66. <hr>
  67. <a name="Binary-Compatibility"></a>
  68. <h2 class="chapter">9 Binary Compatibility</h2>
  69. <a name="index-binary-compatibility"></a>
  70. <a name="index-ABI"></a>
  71. <a name="index-application-binary-interface"></a>
  72. <p>Binary compatibility encompasses several related concepts:
  73. </p>
  74. <dl compact="compact">
  75. <dt><em>application binary interface (ABI)</em></dt>
  76. <dd><p>The set of runtime conventions followed by all of the tools that deal
  77. with binary representations of a program, including compilers, assemblers,
  78. linkers, and language runtime support.
  79. Some ABIs are formal with a written specification, possibly designed
  80. by multiple interested parties. Others are simply the way things are
  81. actually done by a particular set of tools.
  82. </p>
  83. </dd>
  84. <dt><em>ABI conformance</em></dt>
  85. <dd><p>A compiler conforms to an ABI if it generates code that follows all of
  86. the specifications enumerated by that ABI.
  87. A library conforms to an ABI if it is implemented according to that ABI.
  88. An application conforms to an ABI if it is built using tools that conform
  89. to that ABI and does not contain source code that specifically changes
  90. behavior specified by the ABI.
  91. </p>
  92. </dd>
  93. <dt><em>calling conventions</em></dt>
  94. <dd><p>Calling conventions are a subset of an ABI that specify of how arguments
  95. are passed and function results are returned.
  96. </p>
  97. </dd>
  98. <dt><em>interoperability</em></dt>
  99. <dd><p>Different sets of tools are interoperable if they generate files that
  100. can be used in the same program. The set of tools includes compilers,
  101. assemblers, linkers, libraries, header files, startup files, and debuggers.
  102. Binaries produced by different sets of tools are not interoperable unless
  103. they implement the same ABI. This applies to different versions of the
  104. same tools as well as tools from different vendors.
  105. </p>
  106. </dd>
  107. <dt><em>intercallability</em></dt>
  108. <dd><p>Whether a function in a binary built by one set of tools can call a
  109. function in a binary built by a different set of tools is a subset
  110. of interoperability.
  111. </p>
  112. </dd>
  113. <dt><em>implementation-defined features</em></dt>
  114. <dd><p>Language standards include lists of implementation-defined features whose
  115. behavior can vary from one implementation to another. Some of these
  116. features are normally covered by a platform&rsquo;s ABI and others are not.
  117. The features that are not covered by an ABI generally affect how a
  118. program behaves, but not intercallability.
  119. </p>
  120. </dd>
  121. <dt><em>compatibility</em></dt>
  122. <dd><p>Conformance to the same ABI and the same behavior of implementation-defined
  123. features are both relevant for compatibility.
  124. </p></dd>
  125. </dl>
  126. <p>The application binary interface implemented by a C or C++ compiler
  127. affects code generation and runtime support for:
  128. </p>
  129. <ul>
  130. <li> size and alignment of data types
  131. </li><li> layout of structured types
  132. </li><li> calling conventions
  133. </li><li> register usage conventions
  134. </li><li> interfaces for runtime arithmetic support
  135. </li><li> object file formats
  136. </li></ul>
  137. <p>In addition, the application binary interface implemented by a C++ compiler
  138. affects code generation and runtime support for:
  139. </p><ul>
  140. <li> name mangling
  141. </li><li> exception handling
  142. </li><li> invoking constructors and destructors
  143. </li><li> layout, alignment, and padding of classes
  144. </li><li> layout and alignment of virtual tables
  145. </li></ul>
  146. <p>Some GCC compilation options cause the compiler to generate code that
  147. does not conform to the platform&rsquo;s default ABI. Other options cause
  148. different program behavior for implementation-defined features that are
  149. not covered by an ABI. These options are provided for consistency with
  150. other compilers that do not follow the platform&rsquo;s default ABI or the
  151. usual behavior of implementation-defined features for the platform.
  152. Be very careful about using such options.
  153. </p>
  154. <p>Most platforms have a well-defined ABI that covers C code, but ABIs
  155. that cover C++ functionality are not yet common.
  156. </p>
  157. <p>Starting with GCC 3.2, GCC binary conventions for C++ are based on a
  158. written, vendor-neutral C++ ABI that was designed to be specific to
  159. 64-bit Itanium but also includes generic specifications that apply to
  160. any platform.
  161. This C++ ABI is also implemented by other compiler vendors on some
  162. platforms, notably GNU/Linux and BSD systems.
  163. We have tried hard to provide a stable ABI that will be compatible with
  164. future GCC releases, but it is possible that we will encounter problems
  165. that make this difficult. Such problems could include different
  166. interpretations of the C++ ABI by different vendors, bugs in the ABI, or
  167. bugs in the implementation of the ABI in different compilers.
  168. GCC&rsquo;s <samp>-Wabi</samp> switch warns when G++ generates code that is
  169. probably not compatible with the C++ ABI.
  170. </p>
  171. <p>The C++ library used with a C++ compiler includes the Standard C++
  172. Library, with functionality defined in the C++ Standard, plus language
  173. runtime support. The runtime support is included in a C++ ABI, but there
  174. is no formal ABI for the Standard C++ Library. Two implementations
  175. of that library are interoperable if one follows the de-facto ABI of the
  176. other and if they are both built with the same compiler, or with compilers
  177. that conform to the same ABI for C++ compiler and runtime support.
  178. </p>
  179. <p>When G++ and another C++ compiler conform to the same C++ ABI, but the
  180. implementations of the Standard C++ Library that they normally use do not
  181. follow the same ABI for the Standard C++ Library, object files built with
  182. those compilers can be used in the same program only if they use the same
  183. C++ library. This requires specifying the location of the C++ library
  184. header files when invoking the compiler whose usual library is not being
  185. used. The location of GCC&rsquo;s C++ header files depends on how the GCC
  186. build was configured, but can be seen by using the G++ <samp>-v</samp> option.
  187. With default configuration options for G++ 3.3 the compile line for a
  188. different C++ compiler needs to include
  189. </p>
  190. <div class="smallexample">
  191. <pre class="smallexample"> -I<var>gcc_install_directory</var>/include/c++/3.3
  192. </pre></div>
  193. <p>Similarly, compiling code with G++ that must use a C++ library other
  194. than the GNU C++ library requires specifying the location of the header
  195. files for that other library.
  196. </p>
  197. <p>The most straightforward way to link a program to use a particular
  198. C++ library is to use a C++ driver that specifies that C++ library by
  199. default. The <code>g++</code> driver, for example, tells the linker where
  200. to find GCC&rsquo;s C++ library (<samp>libstdc++</samp>) plus the other libraries
  201. and startup files it needs, in the proper order.
  202. </p>
  203. <p>If a program must use a different C++ library and it&rsquo;s not possible
  204. to do the final link using a C++ driver that uses that library by default,
  205. it is necessary to tell <code>g++</code> the location and name of that
  206. library. It might also be necessary to specify different startup files
  207. and other runtime support libraries, and to suppress the use of GCC&rsquo;s
  208. support libraries with one or more of the options <samp>-nostdlib</samp>,
  209. <samp>-nostartfiles</samp>, and <samp>-nodefaultlibs</samp>.
  210. </p>
  211. <hr>
  212. <div class="header">
  213. <p>
  214. Next: <a href="Gcov.html#Gcov" accesskey="n" rel="next">Gcov</a>, Previous: <a href="Objective_002dC.html#Objective_002dC" accesskey="p" rel="prev">Objective-C</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
  215. </div>
  216. </body>
  217. </html>