Developer Guide and Reference

Contents

Specifying Symbol Visibility Explicitly (Linux*
and
macOS*
)

This topic applies to C/C++ applications for Linux*
and
macOS*
only.
You can explicitly set the visibility of an individual symbol using the
visibility
attribute on a data or function declaration. For example:
int i __attribute__ ((visibility("default"))); void __attribute__ ((visibility("hidden"))) x () {...} extern void y() __attribute__ ((visibility("protected")));
The
visibility
declaration attribute accepts one of the five keywords:
  • external
  • default
  • protected
  • hidden
  • internal
The value of the
visibility
declaration attribute overrides the default set by the options
-fpic
,
-fvisibility
,
or
-fno-common
.
If you have a number of symbols for which you wish to specify the same
visibility
attribute, you can set the visibility using one of the five command line options:
  • -fvisibility-external=
    file
  • -fvisibility-default=
    file
  • -fvisibility-protected=
    file
  • -fvisibility-hidden=
    file
  • -fvisibility-internal=
    file
where
file
is the pathname of a file containing