Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

153 lines
7.0KB

  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>Microsoft Windows Variable Attributes (Using the GNU Compiler Collection (GCC))</title>
  21. <meta name="description" content="Microsoft Windows Variable Attributes (Using the GNU Compiler Collection (GCC))">
  22. <meta name="keywords" content="Microsoft Windows Variable Attributes (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="Variable-Attributes.html#Variable-Attributes" rel="up" title="Variable Attributes">
  30. <link href="MSP430-Variable-Attributes.html#MSP430-Variable-Attributes" rel="next" title="MSP430 Variable Attributes">
  31. <link href="MeP-Variable-Attributes.html#MeP-Variable-Attributes" rel="prev" title="MeP Variable Attributes">
  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="Microsoft-Windows-Variable-Attributes"></a>
  62. <div class="header">
  63. <p>
  64. Next: <a href="MSP430-Variable-Attributes.html#MSP430-Variable-Attributes" accesskey="n" rel="next">MSP430 Variable Attributes</a>, Previous: <a href="MeP-Variable-Attributes.html#MeP-Variable-Attributes" accesskey="p" rel="prev">MeP Variable Attributes</a>, Up: <a href="Variable-Attributes.html#Variable-Attributes" accesskey="u" rel="up">Variable Attributes</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="Microsoft-Windows-Variable-Attributes-1"></a>
  68. <h4 class="subsection">6.34.9 Microsoft Windows Variable Attributes</h4>
  69. <p>You can use these attributes on Microsoft Windows targets.
  70. <a href="x86-Variable-Attributes.html#x86-Variable-Attributes">x86 Variable Attributes</a> for additional Windows compatibility
  71. attributes available on all x86 targets.
  72. </p>
  73. <dl compact="compact">
  74. <dt><code>dllimport</code></dt>
  75. <dt><code>dllexport</code></dt>
  76. <dd><a name="index-dllimport-variable-attribute"></a>
  77. <a name="index-dllexport-variable-attribute"></a>
  78. <p>The <code>dllimport</code> and <code>dllexport</code> attributes are described in
  79. <a href="Microsoft-Windows-Function-Attributes.html#Microsoft-Windows-Function-Attributes">Microsoft Windows Function Attributes</a>.
  80. </p>
  81. </dd>
  82. <dt><code>selectany</code></dt>
  83. <dd><a name="index-selectany-variable-attribute"></a>
  84. <p>The <code>selectany</code> attribute causes an initialized global variable to
  85. have link-once semantics. When multiple definitions of the variable are
  86. encountered by the linker, the first is selected and the remainder are
  87. discarded. Following usage by the Microsoft compiler, the linker is told
  88. <em>not</em> to warn about size or content differences of the multiple
  89. definitions.
  90. </p>
  91. <p>Although the primary usage of this attribute is for POD types, the
  92. attribute can also be applied to global C++ objects that are initialized
  93. by a constructor. In this case, the static initialization and destruction
  94. code for the object is emitted in each translation defining the object,
  95. but the calls to the constructor and destructor are protected by a
  96. link-once guard variable.
  97. </p>
  98. <p>The <code>selectany</code> attribute is only available on Microsoft Windows
  99. targets. You can use <code>__declspec (selectany)</code> as a synonym for
  100. <code>__attribute__ ((selectany))</code> for compatibility with other
  101. compilers.
  102. </p>
  103. </dd>
  104. <dt><code>shared</code></dt>
  105. <dd><a name="index-shared-variable-attribute"></a>
  106. <p>On Microsoft Windows, in addition to putting variable definitions in a named
  107. section, the section can also be shared among all running copies of an
  108. executable or DLL. For example, this small program defines shared data
  109. by putting it in a named section <code>shared</code> and marking the section
  110. shareable:
  111. </p>
  112. <div class="smallexample">
  113. <pre class="smallexample">int foo __attribute__((section (&quot;shared&quot;), shared)) = 0;
  114. int
  115. main()
  116. {
  117. /* <span class="roman">Read and write foo. All running
  118. copies see the same value.</span> */
  119. return 0;
  120. }
  121. </pre></div>
  122. <p>You may only use the <code>shared</code> attribute along with <code>section</code>
  123. attribute with a fully-initialized global definition because of the way
  124. linkers work. See <code>section</code> attribute for more information.
  125. </p>
  126. <p>The <code>shared</code> attribute is only available on Microsoft Windows.
  127. </p>
  128. </dd>
  129. </dl>
  130. <hr>
  131. <div class="header">
  132. <p>
  133. Next: <a href="MSP430-Variable-Attributes.html#MSP430-Variable-Attributes" accesskey="n" rel="next">MSP430 Variable Attributes</a>, Previous: <a href="MeP-Variable-Attributes.html#MeP-Variable-Attributes" accesskey="p" rel="prev">MeP Variable Attributes</a>, Up: <a href="Variable-Attributes.html#Variable-Attributes" accesskey="u" rel="up">Variable Attributes</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>
  134. </div>
  135. </body>
  136. </html>