fvisibility
Fvisibility is a compiler feature implemented by GCC and Clang that controls the visibility of symbols in shared libraries. It determines which functions and variables are exposed to the dynamic linker and to external binaries, thereby shaping the library’s public interface. By default, compilers may export many symbols, which can increase the dynamic symbol table and the potential for ABI disputes. fvisibility provides a way to limit or specify symbol exposure.
The feature is used through the -fvisibility option and related flags. Common values are default, hidden, and
There is also -fvisibility-inlines-hidden, which hides inline functions from being emitted as exported symbols, further reducing
Typical usage involves compiling a library with -fvisibility=hidden and explicitly marking the library’s API with visibility("default").
Limitations and scope: fvisibility primarily affects symbols in Unix-like shared libraries. Windows uses a separate export