summaryrefslogtreecommitdiff
path: root/devdocs/gcc~13/structure-layout-pragmas.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/structure-layout-pragmas.html
new repository
Diffstat (limited to 'devdocs/gcc~13/structure-layout-pragmas.html')
-rw-r--r--devdocs/gcc~13/structure-layout-pragmas.html16
1 files changed, 16 insertions, 0 deletions
diff --git a/devdocs/gcc~13/structure-layout-pragmas.html b/devdocs/gcc~13/structure-layout-pragmas.html
new file mode 100644
index 00000000..6ae12cfd
--- /dev/null
+++ b/devdocs/gcc~13/structure-layout-pragmas.html
@@ -0,0 +1,16 @@
+<div class="subsection-level-extent" id="Structure-Layout-Pragmas"> <div class="nav-panel"> <p> Next: <a href="weak-pragmas" accesskey="n" rel="next">Weak Pragmas</a>, Previous: <a href="symbol-renaming-pragmas" accesskey="p" rel="prev">Symbol-Renaming 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="Structure-Layout-Pragmas-1"><span>6.62.10 Structure-Layout Pragmas<a class="copiable-link" href="#Structure-Layout-Pragmas-1"> ΒΆ</a></span></h1> <p>For compatibility with Microsoft Windows compilers, GCC supports a set of <code class="code">#pragma</code> directives that change the maximum alignment of members of structures (other than zero-width bit-fields), unions, and classes subsequently defined. The <var class="var">n</var> value below always is required to be a small power of two and specifies the new alignment in bytes. </p> <ol class="enumerate"> <li> <code class="code">#pragma pack(<var class="var">n</var>)</code> simply sets the new alignment. </li>
+<li> <code class="code">#pragma pack()</code> sets the alignment to the one that was in effect when compilation started (see also command-line option <samp class="option">-fpack-struct[=<var class="var">n</var>]</samp> see <a class="pxref" href="code-gen-options">Options for Code Generation Conventions</a>). </li>
+<li> <code class="code">#pragma pack(push[,<var class="var">n</var>])</code> pushes the current alignment setting on an internal stack and then optionally sets the new alignment. </li>
+<li> <code class="code">#pragma pack(pop)</code> restores the alignment setting to the one saved at the top of the internal stack (and removes that stack entry). Note that <code class="code">#pragma pack([<var class="var">n</var>])</code> does not influence this internal stack; thus it is possible to have <code class="code">#pragma pack(push)</code> followed by multiple <code class="code">#pragma pack(<var class="var">n</var>)</code> instances and finalized by a single <code class="code">#pragma pack(pop)</code>. </li>
+</ol> <p>Some targets, e.g. x86 and PowerPC, support the <code class="code">#pragma ms_struct</code> directive which lays out structures and unions subsequently defined as the documented <code class="code">__attribute__ ((ms_struct))</code>. </p> <ol class="enumerate"> <li> <code class="code">#pragma ms_struct on</code> turns on the Microsoft layout. </li>
+<li> <code class="code">#pragma ms_struct off</code> turns off the Microsoft layout. </li>
+<li> <code class="code">#pragma ms_struct reset</code> goes back to the default layout. </li>
+</ol> <p>Most targets also support the <code class="code">#pragma scalar_storage_order</code> directive which lays out structures and unions subsequently defined as the documented <code class="code">__attribute__ ((scalar_storage_order))</code>. </p> <ol class="enumerate"> <li> <code class="code">#pragma scalar_storage_order big-endian</code> sets the storage order of the scalar fields to big-endian. </li>
+<li> <code class="code">#pragma scalar_storage_order little-endian</code> sets the storage order of the scalar fields to little-endian. </li>
+<li> <code class="code">#pragma scalar_storage_order default</code> goes back to the endianness that was in effect when compilation started (see also command-line option <samp class="option">-fsso-struct=<var class="var">endianness</var></samp> see <a class="pxref" href="c-dialect-options">Options Controlling C Dialect</a>). </li>
+</ol> </div> <div class="nav-panel"> <p> Next: <a href="weak-pragmas">Weak Pragmas</a>, Previous: <a href="symbol-renaming-pragmas">Symbol-Renaming Pragmas</a>, Up: <a href="pragmas">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><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/Structure-Layout-Pragmas.html" class="_attribution-link">https://gcc.gnu.org/onlinedocs/gcc-13.1.0/gcc/Structure-Layout-Pragmas.html</a>
+ </p>
+</div>