Go to the first, previous, next, last section, table of contents.

New GCC syntax for function attributes

To declare that a function does not return, you must now use the `__attribute__' keyword (with two leading and trailing underbars) to write something like this:

void fatal () __attribute__ ((noreturn));

Unfortunately, this new syntax is not compatible with older versions of GCC. Here is an alternative syntax, which works in both the current version and in some older versions:

typedef void voidfn ();
...
volatile voidfn fatal;

ANSI C does not permit the formerly used syntax, `volatile void fatal ();', to have this meaning.

Likewise, to declare that a function has no side effects, so that calls may be deleted or combined, write something like this (which works only with the latest GCC):

int computation () __attribute__ ((const));

or like this (which works in some older versions):

typedef int intfn ();
...
extern const intfn computation;

See section `Declaring Attributes of Functions' in Using GNU CC, for more discussion of function attributes.


Go to the first, previous, next, last section, table of contents.