You copied the Doc URL to your clipboard.

Arm Compiler armclang Reference Guide : __attribute__((visibility("visibility_type"))) variable attribute

__attribute__((visibility("visibility_type"))) variable attribute

This variable attribute affects the visibility of ELF symbols.



Where visibility_type is one of the following:

Default visibility corresponds to external linkage.
The symbol is not placed into the dynamic symbol table, so no other executable or shared library can directly reference it. Indirect references are possible using function pointers.
The symbol is placed into the dynamic symbol table, but references within the defining module bind to the local symbol. That is, another module cannot override the symbol.


This attribute overrides other settings that determine the visibility of symbols.

You can apply this attribute to functions and variables in C and C++. In C++, it can also be applied to class, struct, union, and enum types, and namespace declarations.

In the case of namespace declarations, the visibility attribute applies to all function and variable definitions.


If you do not specify visibility, then the default type is default for extern declarations and hidden for everything else.


int __attribute__((visibility("hidden"))) foo = 1;   // hidden in object file