Specifies the default visibility for global symbols or the visibility for symbols in a file.
None
IA-32, IntelŪ EM64T, IntelŪ ItaniumŪ architecture
Linux: | -fvisibility=keyword -fvisibility-keyword=file |
Windows: | None |
keyword | Specifies the visibility setting. Possible values are: | |
default | Sets visibility to default. | |
extern | Sets visibility to extern. | |
hidden | Sets visibility to hidden. | |
internal | Sets visibility to internal. | |
protected | Sets visibility to protected. |
file | Is the pathname of a file containing the list of symbols whose visibility you want to set. The symbols must be separated by whitespace (spaces, tabs, or newlines). |
-fvisibility=default | The compiler sets visibility of symbols to default. |
This option specifies the default visibility for global symbols (syntax -fvisibility=keyword) or the visibility for symbols in a file (syntax -fvisibility-keyword=file). The second syntax form overrides the first.
Note
These two ways to explicitly set visibility are mutually exclusive. You may set visibility in the declaration, or specify the symbol name in a file, but not both.
Option |
Description |
---|---|
-fvisibility=default -fvisibility=default=file |
Sets visibility of symbols to default. This means other components can reference the symbol, and the symbol definition can be overridden (preempted) by a definition of the same name in another component. |
-fvisibility=extern -fvisibility=extern=file |
Sets visibility of symbols to extern. This means the symbol is treated as though it is defined in another component. It also means that the symbol can be overridden by a definition of the same name in another component. |
-fvisibility=hidden -fvisibility=hidden=file |
Sets visibility of symbols to hidden. This means that other components cannot directly reference the symbol. However, its address may be passed to other components indirectly. |
-fvisibility=internal -fvisibility=internal=file |
Sets visibility of symbols to internal. This means the symbol cannot be referenced outside its defining component, either directly or indirectly. |
-fvisibility=protected -fvisibility=protected=file |
Sets visibility of symbols to protected. This means other components can reference the symbol, but it cannot be overridden by a definition of the same name in another component. |
None
Assume that a file named prot.txt contains symbols a, b, c, d, and e. Now, consider the following:
-fvisibility-protected=prot.txt
This option sets protected visibility for all the symbols in the file.