Who have already used the new GCC option "-fvisibility=hidden" in Mingw+Msys?

Brian Dessent brian@dessent.net
Fri Sep 14 08:38:00 GMT 2007


Duft Markus wrote:

> Huh? Doesn't PE support symbol visibility in shared libraries etc. by
> default, and much, much much longer and better than ELF / gcc? I just
> wonder, because i'm not sure if the same stuff is meant here (I'm
> thinking of dllexport/dllimport and such...)

If you want to call dllimport/dllexport visibility then fine, but it's
not the same kind of visibility that -fvisibility=hidden refers to.

If you want to selectively expose only certain symbols on PE you do it
by declaring them __declspec(dllexport) or linking with a def file that
lists them.  In that sense the default PE visibility is already hidden
since you have to manually mark everything you want exported.  For ease
in porting software however, the PE linker enables auto-export mode if
you do neither of these things (no __declspec(dllexport) used anywhere
and no def file) which means everything is exported.

In any case, this doesn't change the fact that -fvisibility and/or
__attribute__ ((visibility ("foo")) are only relevant on ELF.  Or put
differently, the two platforms handle things in different ways so the
ELF way is not applicable to PE.

Brian



More information about the Gcc-help mailing list