-qvisibility
Category
Pragma equivalent
#pragma GCC visibility push (default | protected | hidden | internal)
#pragma GCC visibility pop
Purpose
Specifies the visibility attribute for external linkage entities in object files. The external linkage entities have the visibility attribute that is specified by the -qvisibility option if they do not get visibility attributes from pragma directives, explicitly specified attributes, or propagation rules.
Syntax
.-unspecified-. >>- -q--visibility--=--+-default-----+------------------------->< +-hidden------+ +-protected---+ '-internal----'
Defaults
-qvisibility=unspecified
Parameters
- unspecified
- Indicates that the affected external linkage entities do not have visibility attributes. Whether these entities are exported in shared libraries depends on the specified export list or the one that is generated by the compiler.
- default
- Indicates that the affected external linkage entities have the default visibility attribute. These entities are exported in shared libraries, and they can be preempted.
- protected
- Indicates that the affected external linkage entities have the protected visibility attribute. These entities are exported in shared libraries, but they cannot be preempted.
- hidden
- Indicates that the affected external linkage entities have the hidden visibility attribute. These entities are not exported in shared libraries, but their addresses can be referenced indirectly through pointers.
- internal
- Indicates that the affected external linkage entities have the internal visibility attribute. These entities are not exported in shared libraries, and their addresses are not available to other modules in shared libraries.
Usage
The -qvisibility option globally sets visibility attributes for external linkage entities to describe whether and how an entity defined in one module can be referenced or used in other modules. Entity visibility attributes affect entities with external linkage only, and cannot increase the visibility of other entities. Entity preemption occurs when an entity definition is resolved at link time, but is replaced with another entity definition at run time.
Predefined macros
None.
Examples
To set external linkage entities with the protected visibility attribute in compilation unit myprogram.c, compile myprogram.c with the -qvisibility=protected option.
xlc myprogram.c -qvisibility=protected -c
All the external linkage entities in the myprogram.c file have the protected visibility attribute if they do not get visibility attributes from pragma directives, explicitly specified attributes, or propagation rules.
Related information
- -qmkshrobj
- -G
- #pragma GCC visibility push, #pragma GCC visibility pop
- Using visibility attributes (IBM extension)
- External linkage
- The visibility variable attribute (IBM extension)
- The visibility function attribute (IBM extension)
- The visibility type attribute (C++ only) (IBM extension)
- The visibility namespace attribute (C++ only) (IBM extension)