I was going through the source of some of the standard headers included with gcc (in /usr/include/c++/
) and found the following at the top of every header:
namespace std _GLIBCXX_VISIBILITY(default)
What exactly is _GLIBCXX_VISIBILITY(default)
?
It's a preprocessor macro. And is defined as:
#if _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY
#define _GLIBCXX_VISIBILITY(V) __attribute__ ((__visibility__ (#V)))
#else
#define _GLIBCXX_VISIBILITY(V)
#endif
So if _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY
is true then in your case it will expand to:
__attribute__ (( __visibility__ ("default")))
else if _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY
is false it will do nothing.
The __visibility__
attribute is used for defining the visibility of the symbols in a DSO file. Using "hidden" instead of "default" can be used to hide symbols from things outside the DSO.
For example:
__attribute__ ((__visibility__("default"))) void foo();
__attribute__ ((__visibility__("hidden"))) void bar();
The function foo()
would be useable from outside the DSO whereas bar()
is basically private and can only be used inside the DSO.
You can read a bit more about the __visibility__
attribute here: https://gcc.gnu.org/wiki/Visibility
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With