summaryrefslogtreecommitdiff
path: root/devdocs/gcc~13/microsoft-windows-variable-attributes.html
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
committerCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
commit754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch)
treef1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/gcc~13/microsoft-windows-variable-attributes.html
new repository
Diffstat (limited to 'devdocs/gcc~13/microsoft-windows-variable-attributes.html')
-rw-r--r--devdocs/gcc~13/microsoft-windows-variable-attributes.html24
1 files changed, 24 insertions, 0 deletions
diff --git a/devdocs/gcc~13/microsoft-windows-variable-attributes.html b/devdocs/gcc~13/microsoft-windows-variable-attributes.html
new file mode 100644
index 00000000..62d65a86
--- /dev/null
+++ b/devdocs/gcc~13/microsoft-windows-variable-attributes.html
@@ -0,0 +1,24 @@
+<div class="subsection-level-extent" id="Microsoft-Windows-Variable-Attributes"> <div class="nav-panel"> <p> Next: <a href="msp430-variable-attributes" accesskey="n" rel="next">MSP430 Variable Attributes</a>, Previous: <a href="m32r_002fd-variable-attributes" accesskey="p" rel="prev">M32R/D Variable Attributes</a>, Up: <a href="variable-attributes" accesskey="u" rel="up">Specifying Attributes of Variables</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="Microsoft-Windows-Variable-Attributes-1"><span>6.34.9 Microsoft Windows Variable Attributes<a class="copiable-link" href="#Microsoft-Windows-Variable-Attributes-1"> ¶</a></span></h1> <p>You can use these attributes on Microsoft Windows targets. <a class="ref" href="variable-attributes">x86 Variable Attributes</a> for additional Windows compatibility attributes available on all x86 targets. </p> <dl class="table"> <dt>
+ <span><code class="code">dllimport</code><a class="copiable-link" href="#index-dllimport-variable-attribute"> ¶</a></span>
+</dt> <dt><code class="code">dllexport</code></dt> <dd>
+<p>The <code class="code">dllimport</code> and <code class="code">dllexport</code> attributes are described in <a class="ref" href="microsoft-windows-function-attributes">Microsoft Windows Function Attributes</a>. </p> </dd> <dt>
+<span><code class="code">selectany</code><a class="copiable-link" href="#index-selectany-variable-attribute"> ¶</a></span>
+</dt> <dd>
+<p>The <code class="code">selectany</code> attribute causes an initialized global variable to have link-once semantics. When multiple definitions of the variable are encountered by the linker, the first is selected and the remainder are discarded. Following usage by the Microsoft compiler, the linker is told <em class="emph">not</em> to warn about size or content differences of the multiple definitions. </p> <p>Although the primary usage of this attribute is for POD types, the attribute can also be applied to global C++ objects that are initialized by a constructor. In this case, the static initialization and destruction code for the object is emitted in each translation defining the object, but the calls to the constructor and destructor are protected by a link-once guard variable. </p> <p>The <code class="code">selectany</code> attribute is only available on Microsoft Windows targets. You can use <code class="code">__declspec (selectany)</code> as a synonym for <code class="code">__attribute__ ((selectany))</code> for compatibility with other compilers. </p> </dd> <dt>
+<span><code class="code">shared</code><a class="copiable-link" href="#index-shared-variable-attribute"> ¶</a></span>
+</dt> <dd>
+<p>On Microsoft Windows, in addition to putting variable definitions in a named section, the section can also be shared among all running copies of an executable or DLL. For example, this small program defines shared data by putting it in a named section <code class="code">shared</code> and marking the section shareable: </p> <div class="example smallexample"> <pre class="example-preformatted" data-language="cpp">int foo __attribute__((section ("shared"), shared)) = 0;
+
+int
+main()
+{
+ /* <span class="r">Read and write foo. All running
+ copies see the same value.</span> */
+ return 0;
+}</pre>
+</div> <p>You may only use the <code class="code">shared</code> attribute along with <code class="code">section</code> attribute with a fully-initialized global definition because of the way linkers work. See <code class="code">section</code> attribute for more information. </p> <p>The <code class="code">shared</code> attribute is only available on Microsoft Windows. </p> </dd> </dl> </div> <div class="nav-panel"> <p> Next: <a href="msp430-variable-attributes">MSP430 Variable Attributes</a>, Previous: <a href="m32r_002fd-variable-attributes">M32R/D Variable Attributes</a>, Up: <a href="variable-attributes">Specifying Attributes of Variables</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><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/Microsoft-Windows-Variable-Attributes.html" class="_attribution-link">https://gcc.gnu.org/onlinedocs/gcc-13.1.0/gcc/Microsoft-Windows-Variable-Attributes.html</a>
+ </p>
+</div>