4.4.6. Marking functions as static

At the optimization levels -O2 and -O3, the compiler is able to automatically inline a function if it is sensible to do so, even when the function is not declared as __inline or inline.

Note

To control the automatic inlining of functions at higher optimization levels, use the --[no_]autoinline command-line option.

Unless a function is explicitly declared as static (or __inline), the compiler has to retain the out-of-line version of it in the object file in case it is called from some other module. The linker is unable to remove unused out-of-line functions from an object, unless unused out-of-line functions are placed into their own sections using linker feedback.

If you fail to declare functions that are never called from outside a module as static, your code can be adversely affected. In particular, you might have:

Because of these problems, declare functions as static when you are sure that they can never be called from another module.

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