ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libecb/ecb.pod
(Generate patch)

Comparing libecb/ecb.pod (file contents):
Revision 1.59 by sf-exg, Mon Jan 26 12:04:56 2015 UTC vs.
Revision 1.60 by sf-exg, Wed Feb 11 19:16:12 2015 UTC

163C<__x86_64> stands for, well, the x86-64 ABI, making these macros 163C<__x86_64> stands for, well, the x86-64 ABI, making these macros
164necessary. 164necessary.
165 165
166=back 166=back
167 167
168=head2 GCC ATTRIBUTES 168=head2 ATTRIBUTES
169 169
170A major part of libecb deals with GCC attributes. These are additional 170A major part of libecb deals with additional attributes that can be
171attributes that you can assign to functions, variables and sometimes even 171assigned to functions, variables and sometimes even types - much like
172types - much like C<const> or C<volatile> in C. 172C<const> or C<volatile> in C. They are implemented using either GCC
173 173attributes or other compiler/language specific features. Attributes
174While GCC allows declarations to show up in many surprising places,
175but not in many expected places, the safest way is to put attribute
176declarations before the whole declaration: 174declarations must be put before the whole declaration:
177 175
178 ecb_const int mysqrt (int a); 176 ecb_const int mysqrt (int a);
179 ecb_unused int i; 177 ecb_unused int i;
180 178
181For variables, it is often nicer to put the attribute after the name, and
182avoid multiple declarations using commas:
183
184 int i ecb_unused;
185
186=over 4 179=over 4
187
188=item ecb_attribute ((attrs...))
189
190A simple wrapper that expands to C<__attribute__((attrs))> on GCC 3.1+ and
191Clang 2.8+, and to nothing on other compilers, so the effect is that only
192GCC and Clang see these.
193
194Example: use the C<deprecated> attribute on a function.
195
196 ecb_attribute((__deprecated__)) void
197 do_not_use_me_anymore (void);
198 180
199=item ecb_unused 181=item ecb_unused
200 182
201Marks a function or a variable as "unused", which simply suppresses a 183Marks a function or a variable as "unused", which simply suppresses a
202warning by GCC when it detects it as unused. This is useful when you e.g. 184warning by GCC when it detects it as unused. This is useful when you e.g.
218Similar to C<ecb_unused>, but marks a function, variable or type as 200Similar to C<ecb_unused>, but marks a function, variable or type as
219deprecated. This makes some compilers warn when the type is used. 201deprecated. This makes some compilers warn when the type is used.
220 202
221=item ecb_inline 203=item ecb_inline
222 204
223This is not actually an attribute, but you use it like one. It expands
224either to C<static inline> or to just C<static>, if inline isn't 205Expands either to C<static inline> or to just C<static>, if inline
225supported. It should be used to declare functions that should be inlined, 206isn't supported. It should be used to declare functions that should be
226for code size or speed reasons. 207inlined, for code size or speed reasons.
227 208
228Example: inline this function, it surely will reduce codesize. 209Example: inline this function, it surely will reduce codesize.
229 210
230 ecb_inline int 211 ecb_inline int
231 negmul (int a, int b) 212 negmul (int a, int b)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines