Warning message with usage of visibility hidden with wrapper class

Jonathan Wakely jwakely.gcc@gmail.com
Thu May 31 09:03:00 GMT 2012


On 31 May 2012 02:42, Christopher Sigman <c.s.sigman@gmail.com> wrote:
> Hi everyone,
>
> Attached is some example code that exhibits the issue.  In terms of

A simpler example is

struct __attribute__ ((visibility("hidden"))) Hidden
{
  int something;
};

template <typename T>
struct Visible
{
  Hidden inner;
};

int main()
{
  Visible<int> i;
}


> GCC versions, I think we've seen it in everything from 4.1.2 on, but I
> know for a fact that I see it in 4.4.x, and 4.5.1.  I know that if I

It's still present in the latest versions.

> add -fvisibility=hidden to compilation of anything linking to the
> library resolves the warning,

That's because it gives Visible<int> hidden visibility.

> but as I said before, I'm trying to
> understand why we're getting the warning with it as it is (in our
> actual code, we can't set the default visibility to hidden on
> libraries or executables linking to those libraries at the moment).

The compiler is warning you that if you're trying to make Visible<int>
visible outside a shared library then one of its members has hidden
visibility and can't be exported. It's irrelevant that it's a private
member.



More information about the Gcc-help mailing list