Red Hat ENTERPRISE LINUX 4 Manual page 159

Hide thumbs Also See for ENTERPRISE LINUX 4:
Table of Contents

Advertisement

Chapter 6. Extensions to the C Language Family
The attribute
noreturn
to declare that a function does not return, which works in the current version and in some older
versions, is as follows:
typedef void voidfn ();
volatile voidfn fatal;
noinline
This function attribute prevents a function from being considered for inlining.
always_inline
Generally, functions are not inlined unless optimization is specified. For functions declared in-
line, this attribute inlines the function even if no optimization level was specified.
pure
Many functions have no effects except the return value and their return value depends only on
the parameters and/or global variables. Such a function can be subject to common subexpression
elimination and loop optimization just as an arithmetic operator would be. These functions should
be declared with the attribute
int square (int) __attribute__ ((pure));
says that the hypothetical function
Some of common examples of pure functions are
tions are functions with infinite loops or those depending on volatile memory or other system
resource, that may change between two consecutive calls (such as
vironment).
The attribute
pure
const
Many functions do not examine any values except their arguments, and have no effects except the
return value. Basically this is just slightly more strict class than the
function is not allowed to read global memory.
Note that a function that has pointer arguments and examines the data pointed to must not be
declared
const
It does not make sense for a
The attribute
const
declare that a function has no side effects, which works in the current version and in some older
versions, is as follows:
typedef int intfn ();
extern const intfn square;
This approach does not work in GNU C++ from 2.6.0 on, since the language specifies that the
must be attached to the return value.
const
nothrow
The
attribute is used to inform the compiler that a function cannot throw an exception.
nothrow
For example, most functions in the standard C library can be guaranteed not to throw an exception
with the notable exceptions of
attribute is not implemented in GCC versions earlier than 3.2.
nothrow
is not implemented in GCC versions earlier than 2.5. An alternative way
. For example,
pure
square
is not implemented in GCC versions earlier than 2.96.
. Likewise, a function that calls a non-
function to return
const
is not implemented in GCC versions earlier than 2.5. An alternative way to
qsort
is safe to call fewer times than the program says.
or
strlen
const
.
void
and
that take function pointer arguments. The
bsearch
. Interesting non-pure func-
memcmp
in a multithreading en-
feof
attribute above, since
pure
function usually must not be
151
.
const

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the ENTERPRISE LINUX 4 and is the answer not in the manual?

Table of Contents