4.3.4. Placing ARM function qualifiers

Many ARM keyword extension modify the behavior or calling sequence of a function. For example, __pure, __irq, __swi, __swi_indirect,__softfp, and __value_in_regs all behave in this way.

These function modifiers all have a common syntax. A function modifier such as __pure can qualify a function declaration either:

For simple function declarations, each syntax is unambiguous. However, for a function whose return type or arguments are function pointers, the prefix syntax is imprecise. For example, the following function returns a function pointer, but it is not clear whether __pure modifies the function itself or its returned pointer type:

__pure int (*foo(int)) (int); /* declares 'foo' as a (pure?) function that
                                 returns a pointer to a (pure?) function.
                                 It is ambiguous which of the two function
                                 types is pure. */

In fact, the single __pure keyword at the front of the declaration of foo modifies both foo itself and the function pointer type returned by foo.

In contrast, the postfix syntax because it enables a clear distinction between whether __pure applies to the argument, the return type, or the base function, when declaring a function whose argument and return types are function pointers. For example:

int (*foo1(int) __pure) (int);        /* foo1 is a pure function returning
                                         a pointer to a normal function */
int (*foo2(int)) (int) __pure;        /* foo2 is a function returning
                                         a pointer to a pure function
int (*foo3(int) __pure) (int) __pure; /* foo3 is a pure function returning
                                         a pointer to a pure function */

In this example:

Because the postfix syntax is more precise than the prefix syntax, it is recommended that, where possible, you make use of the postfix syntax when qualifying functions with ARM function modifiers.

Copyright © 2002-2007 ARM Limited. All rights reserved.ARM DUI 0205H