Recommendation of postfix syntax when qualifying functions with ARM function modifiers
You can use function modifiers such as __pure either prefix or postfix, that is before the function declaration or after the parameter list. ARM recommends using the more precise postfix syntax.
Many ARM keyword extensions 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:
Before the function declaration. For example:
__pure int foo(int);
After the closing parenthesis on the parameter list. For example:
int foo(int) __pure;
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 enables 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:
foo1 and foo3 are modified themselves.
foo2 and foo3 return a pointer to a modified function.
The functions foo3 and foo are identical.
Because the postfix syntax is more precise than the prefix syntax, ARM recommends that, where possible, you make use of the postfix syntax when qualifying functions with ARM function modifiers.