__weak
Syntax
See Syntax for object attributes.
Description
Using the __weak object attribute on an external declaration of a symbol makes all references to that symbol in the module weak.
Using the __weak object attribute on a public definition of a symbol makes that definition a weak definition.
The linker will not include a module from a library solely to satisfy weak references to a symbol, nor will the lack of a definition for a weak reference result in an error. If no definition is included, the address of the object will be zero.
When linking, a symbol can have any number of weak definitions, and at most one non-weak definition. If the symbol is needed, and there is a non-weak definition, this definition will be used. If there is no non-weak definition, one of the weak definitions will be used.
Example
extern __weak int foo; /* A weak reference. */
__weak void bar(void) /* A weak definition. */
{
/* Increment foo if it was included. */
if (&foo != 0)
++foo;
}