source: public/doc/gnu-c/Attributes.html@ 02598c2

Last change on this file since 02598c2 was 02598c2, checked in by Mikhail Kirillov <w96k@…>, on Oct 6, 2022 at 12:36:29 PM

Add gnu-c

  • Property mode set to 100644
File size: 6.7 KB
Line 
1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2<html>
3<!-- Copyright (C) 2022 Richard Stallman and Free Software Foundation, Inc.
4
5(The work of Trevis Rothwell and Nelson Beebe has been assigned or
6licensed to the FSF.)
7
8Permission is granted to copy, distribute and/or modify this document
9under the terms of the GNU Free Documentation License, Version 1.3 or
10any later version published by the Free Software Foundation; with the
11Invariant Sections being "GNU General Public License," with the
12Front-Cover Texts being "A GNU Manual," and with the Back-Cover
13Texts as in (a) below. A copy of the license is included in the
14section entitled "GNU Free Documentation License."
15
16(a) The FSF's Back-Cover Text is: "You have the freedom to copy and
17modify this GNU manual. Buying copies from the FSF supports it in
18developing GNU and promoting software freedom." -->
19<!-- Created by GNU Texinfo 6.7, http://www.gnu.org/software/texinfo/ -->
20<head>
21<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
22<title>Attributes (GNU C Language Manual)</title>
23
24<meta name="description" content="Attributes (GNU C Language Manual)">
25<meta name="keywords" content="Attributes (GNU C Language Manual)">
26<meta name="resource-type" content="document">
27<meta name="distribution" content="global">
28<meta name="Generator" content="makeinfo">
29<link href="index.html" rel="start" title="Top">
30<link href="Symbol-Index.html" rel="index" title="Symbol Index">
31<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
32<link href="index.html" rel="up" title="Top">
33<link href="Signals.html" rel="next" title="Signals">
34<link href="Digraphs.html" rel="prev" title="Digraphs">
35<style type="text/css">
36<!--
37a.summary-letter {text-decoration: none}
38blockquote.indentedblock {margin-right: 0em}
39div.display {margin-left: 3.2em}
40div.example {margin-left: 3.2em}
41div.lisp {margin-left: 3.2em}
42kbd {font-style: oblique}
43pre.display {font-family: inherit}
44pre.format {font-family: inherit}
45pre.menu-comment {font-family: serif}
46pre.menu-preformatted {font-family: serif}
47span.nolinebreak {white-space: nowrap}
48span.roman {font-family: initial; font-weight: normal}
49span.sansserif {font-family: sans-serif; font-weight: normal}
50ul.no-bullet {list-style: none}
51-->
52</style>
53
54
55</head>
56
57<body lang="en">
58<span id="Attributes"></span><div class="header">
59<p>
60Next: <a href="Signals.html" accesskey="n" rel="next">Signals</a>, Previous: <a href="Digraphs.html" accesskey="p" rel="prev">Digraphs</a>, Up: <a href="index.html" accesskey="u" rel="up">Top</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Symbol-Index.html" title="Index" rel="index">Index</a>]</p>
61</div>
62<hr>
63<span id="Attributes-in-Declarations"></span><h2 class="appendix">Appendix D Attributes in Declarations</h2>
64<span id="index-attributes"></span>
65<span id="index-_005f_005fattribute_005f_005f"></span>
66
67<p>You can specify certain additional requirements in a declaration, to
68get fine-grained control over code generation, and helpful
69informational messages during compilation. We use a few attributes in
70code examples throughout this manual, including
71</p>
72<dl compact="compact">
73<dt><code>aligned</code></dt>
74<dd><p>The <code>aligned</code> attribute specifies a minimum alignment for a
75variable or structure field, measured in bytes:
76</p>
77<div class="example">
78<pre class="example">int foo __attribute__ ((aligned (8))) = 0;
79</pre></div>
80
81<p>This directs GNU C to allocate <code>foo</code> at an address that is a
82multiple of 8 bytes. However, you can&rsquo;t force an alignment bigger
83than the computer&rsquo;s maximum meaningful alignment.
84</p>
85</dd>
86<dt><code>packed</code></dt>
87<dd><p>The <code>packed</code> attribute specifies to compact the fields of a
88structure by not leaving gaps between fields. For example,
89</p>
90<div class="example">
91<pre class="example">struct __attribute__ ((packed)) bar
92{
93 char a;
94 int b;
95};
96</pre></div>
97
98<p>allocates the integer field <code>b</code> at byte 1 in the structure,
99immediately after the character field <code>a</code>. The packed structure
100is just 5 bytes long (assuming <code>int</code> is 4 bytes) and its
101alignment is 1, that of <code>char</code>.
102</p>
103</dd>
104<dt><code>deprecated</code></dt>
105<dd><p>Applicable to both variables and functions, the <code>deprecated</code>
106attribute tells the compiler to issue a warning if the variable or
107function is ever used in the source file.
108</p>
109<div class="example">
110<pre class="example">int old_foo __attribute__ ((deprecated));
111
112int old_quux () __attribute__ ((deprecated));
113</pre></div>
114
115</dd>
116<dt><code>__noinline__</code></dt>
117<dd><p>The <code>__noinline__</code> attribute, in a function&rsquo;s declaration or
118definition, specifies never to inline calls to that function. All
119calls to that function, in a compilation unit where it has this
120attribute, will be compiled to invoke the separately compiled
121function. See <a href="Inline-Function-Definitions.html">Inline Function Definitions</a>.
122</p>
123</dd>
124<dt><code>__noclone__</code></dt>
125<dd><p>The <code>__noclone__</code> attribute, in a function&rsquo;s declaration or
126definition, specifies never to clone that function. Thus, there will
127be only one compiled version of the function. See <a href="Label-Value-Caveats.html">Label Value Caveats</a>, for more information about cloning.
128</p>
129</dd>
130<dt><code>always_inline</code></dt>
131<dd><p>The <code>always_inline</code> attribute, in a function&rsquo;s declaration or
132definition, specifies to inline all calls to that function (unless
133something about the function makes inlining impossible). This applies
134to all calls to that function in a compilation unit where it has this
135attribute. See <a href="Inline-Function-Definitions.html">Inline Function Definitions</a>.
136</p>
137</dd>
138<dt><code>gnu_inline</code></dt>
139<dd><p>The <code>gnu_inline</code> attribute, in a function&rsquo;s declaration or
140definition, specifies to handle the <code>inline</code> keywprd the way GNU
141C originally implemented it, many years before ISO C said anything
142about inlining. See <a href="Inline-Function-Definitions.html">Inline Function Definitions</a>.
143</p></dd>
144</dl>
145
146<p>For full documentation of attributes, see the GCC manual.
147See <a href="https://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html#Attribute-Syntax">System Headers</a> in <cite>Using
148the GNU Compiler Collection</cite>.
149</p>
150<hr>
151<div class="header">
152<p>
153Next: <a href="Signals.html" accesskey="n" rel="next">Signals</a>, Previous: <a href="Digraphs.html" accesskey="p" rel="prev">Digraphs</a>, Up: <a href="index.html" accesskey="u" rel="up">Top</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Symbol-Index.html" title="Index" rel="index">Index</a>]</p>
154</div>
155
156
157
158</body>
159</html>
Note: See TracBrowser for help on using the repository browser.