The visibility variable attribute (IBM extension)

The visibility variable attribute describes whether and how a variable defined in one module can be referenced or used in other modules. The visibility attribute affects only variables with external linkage. By using this feature, you can make a shared library smaller and decrease the possibility of symbol collision. For details, see Using visibility attributes.

Read syntax diagramSkip visual syntax diagram
visibility variable attribute syntax

>>-__attribute__------------------------------------------------>

>--((--+-visibility-----+--(--+-"default"---+--)--))-----------><
       '-__visibility__-'     +-"protected"-+          
                              +-"hidden"----+          
                              '-"internal"--'          

Example

In the following example, the visibility attribute of variable a is protected, and that of variable b is hidden:
struct str{
   int var;
};
int a __attribute__((visibility("protected")));
struct str __attribute__((visibility("hidden"))) b;