Intel® C++ Compiler 16.0 User and Reference Guide
This topic applies to
C/C++ applications for Linux* and OS X* only.
You can explicitly set the visibility of an individual symbol using the visibility attribute on a data or function declaration. For example:
int i __attribute__ ((visibility("default"))); void __attribute__ ((visibility("hidden"))) x () {...} extern void y() __attribute__ ((visibility("protected")));
The visibility declaration attribute accepts one of the five keywords:
external
default
protected
hidden
internal
The value of the visibility declaration attribute overrides the default set by the options -fvisibility, -fpic, or -fno-common attributes.
If you have a number of symbols for which you wish to specify the same visibility attribute, you can set the visibility using one of the five command line options:
-fvisibility-external=file
-fvisibility-default=file
-fvisibility-protected=file
-fvisibility-hidden=file
-fvisibility-internal=file
where file is the pathname of a file containing a list of the symbol names whose visibility you wish to set.
The symbol names in the file are separated by white space (blanks, TAB characters, or newlines). For example, the command line option: -fvisibility-protected=prot.txt, where file prot.txt contains:
a b c d e
This sets protected visibility for symbols a, b, c, d, and e.
This has the same effect as __attribute__ ((visibility=("protected"))) on the declaration for each of the symbols.
These two ways to explicitly set visibility are mutually exclusive– you may use __attribute((visibility())) on the declaration or specify the symbol name in a file, but not both.
You can set the default visibility for symbols using one of the command line options:
-fvisibility=external
-fvisibility=default
-fvisibility=protected
-fvisibility=hidden
-fvisibility=internal
This option sets the visibility for symbols not specified in a visibility list file and that do not have __attribute__ ((visibility=())) in their declaration. For example, the command line options: -fvisibility=protected -fvisibility-default=prot.txt, where file prot.txt is as previously described, will cause all global symbols except a, b, c, d, and e to have protected visibility. Those five symbols, however, will have default visibility, and thus will be preemptable.