summaryrefslogtreecommitdiff
path: root/devdocs/gcc~13/alignment.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/alignment.html
new repository
Diffstat (limited to 'devdocs/gcc~13/alignment.html')
-rw-r--r--devdocs/gcc~13/alignment.html7
1 files changed, 7 insertions, 0 deletions
diff --git a/devdocs/gcc~13/alignment.html b/devdocs/gcc~13/alignment.html
new file mode 100644
index 00000000..803274df
--- /dev/null
+++ b/devdocs/gcc~13/alignment.html
@@ -0,0 +1,7 @@
+<div class="section-level-extent" id="Alignment"> <div class="nav-panel"> <p> Next: <a href="inline" accesskey="n" rel="next">An Inline Function is As Fast As a Macro</a>, Previous: <a href="character-escapes" accesskey="p" rel="prev">The Character <kbd class="key">ESC</kbd> in Constants</a>, Up: <a href="c-extensions" accesskey="u" rel="up">Extensions to the C Language Family</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="section" id="Determining-the-Alignment-of-Functions_002c-Types-or-Variables"><span>6.44 Determining the Alignment of Functions, Types or Variables<a class="copiable-link" href="#Determining-the-Alignment-of-Functions_002c-Types-or-Variables"> ΒΆ</a></span></h1> <p>The keyword <code class="code">__alignof__</code> determines the alignment requirement of a function, object, or a type, or the minimum alignment usually required by a type. Its syntax is just like <code class="code">sizeof</code> and C11 <code class="code">_Alignof</code>. </p> <p>For example, if the target machine requires a <code class="code">double</code> value to be aligned on an 8-byte boundary, then <code class="code">__alignof__ (double)</code> is 8. This is true on many RISC machines. On more traditional machine designs, <code class="code">__alignof__ (double)</code> is 4 or even 2. </p> <p>Some machines never actually require alignment; they allow references to any data type even at an odd address. For these machines, <code class="code">__alignof__</code> reports the smallest alignment that GCC gives the data type, usually as mandated by the target ABI. </p> <p>If the operand of <code class="code">__alignof__</code> is an lvalue rather than a type, its value is the required alignment for its type, taking into account any minimum alignment specified by attribute <code class="code">aligned</code> (see <a class="pxref" href="common-variable-attributes">Common Variable Attributes</a>). For example, after this declaration: </p> <div class="example smallexample"> <pre class="example-preformatted" data-language="cpp">struct foo { int x; char y; } foo1;</pre>
+</div> <p>the value of <code class="code">__alignof__ (foo1.y)</code> is 1, even though its actual alignment is probably 2 or 4, the same as <code class="code">__alignof__ (int)</code>. It is an error to ask for the alignment of an incomplete type other than <code class="code">void</code>. </p> <p>If the operand of the <code class="code">__alignof__</code> expression is a function, the expression evaluates to the alignment of the function which may be specified by attribute <code class="code">aligned</code> (see <a class="pxref" href="common-function-attributes">Common Function Attributes</a>). </p> </div> <div class="nav-panel"> <p> Next: <a href="inline">An Inline Function is As Fast As a Macro</a>, Previous: <a href="character-escapes">The Character <kbd class="key">ESC</kbd> in Constants</a>, Up: <a href="c-extensions">Extensions to the C Language Family</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/Alignment.html" class="_attribution-link">https://gcc.gnu.org/onlinedocs/gcc-13.1.0/gcc/Alignment.html</a>
+ </p>
+</div>