Datasheet
ARM Compiler Reference
ARM DUI 0067D Copyright © 1999-2001 ARM Limited. All rights reserved. 3-9
__inline int f(int x) {return x*5+1;}
int g(int x, int y) {return f(x) + f(y);}
The compiler compiles functions inline when
__inline
is used and the
functions are not too large. Large functions are not compiled inline
because they can adversely affect code density and performance. See
Defining optimization criteria on page 2-24 for information on
command-line options that affect inlining.
__weak
This specifies an
extern
function or object declaration that, if not present,
does not cause the linker to fault an unresolved reference. The linker does
not load the function or object from a library unless another compilation
uses the function or object non-weakly. If the reference remains
unresolved, its value is assumed to be
NULL
. See the ADS Linker and
Utilities Guide for details on library searching.
If the reference is made from code that compiles to a Branch or Branch
Link instruction, the reference is resolved as branching to the next
instruction. This effectively makes the branch a no-op:
__weak void f(void);
...
f(); // call f weakly
A function or object cannot be used both weakly and non-weakly in the
same compilation. For example the following code uses
f()
weakly from
g()
and
h()
:
void f(void);
void g() {f();}
__weak void f(void);
void h() {f();}
It is not possible to use a function or object weakly from the same
compilation that defines the function or object. The code below uses
f()
non-weakly from
h()
:
__weak void f(void);
void h() {f();}
void f() {}
3.1.3 Variable declaration keywords
This section describes the implementation of various standard and ARM-specific
variable declaration keywords. Standard C or C++ keywords that do not have
ARM-specific behavior or restrictions are not documented. See also Type qualifiers on
page 3-12 for information on qualifiers such as
volatile
and
__packed