#pragma weak function-name1 [= function-name2]
Use weak to define a weak global symbol. This pragma is used mainly in source files for building libraries. The linker does not warn you if it cannot resolve a weak symbol.
The following directive defines bar to be a weak symbol. No error messages are generated if the linker cannot find a definition for a function named bar.
#pragma weak bar
The following directive instructs the linker to resolves any references to bar to bar if it is defined anywhere in the program, and to foo otherwise.
#pragma weak bar = foo
You must declare a function before you use it in a weak pragma. For example:
extern void bar(int); extern void _bar(int); #pragma weak _bar=bar
The effects of using #pragma weak are:
If your program calls but does not define function-name1, the linker uses the definition from the library.
If your program defines its own version of function-name1, then the program definition is used, and the weak global definition of function-name1 in the library is not used.
If the program directly calls function-name2, the definition from the library is used; a duplicate definition of function-name2 causes an error.
See the Solaris Linker and Libraries Guide for more information.
The names in the pragma must be the names a seen by the linker, which means the "mangled" name if the function has C++ linkage.