Warning message with usage of visibility hidden with wrapper class

View: New views
4 Messages — Rating Filter:   Alert me  

Warning message with usage of visibility hidden with wrapper class

by Christopher Sigman :: Rate this Message:

| View Threaded | Show Only this Message

Hi all,

My team at work and I have started to utilize the visibility
attributes in gcc so that we are building 'nix libraries whose public
symbols are in-line with our Windows builds. With some of our code
though, we're noticing warnings about parts being declared with
greater visibility.  As far as we've been able to determine, there's
nothing being executed incorrectly, but we'd like to understand the
warning before ignoring it.

The code in question is basically set up like this:

class __attribute__ ((visibility ("hidden"))) SomeClass
{
  ...
}

template <T>
class WrappingSomeClass
{
...
  void someFunc()
  {
    SomeClass var;
    ...
  }
...
}

Where the warning occurs on usage of SomeClass in WrappingSomeClass.
Any code using this example links to the library with SomeClass in it.
Any help you can give would be appreciated, and if my super
simplification is overly so, let me know and I can give it in more
detail.

--
CSS

Re: Warning message with usage of visibility hidden with wrapper class

by Jonathan Wakely-4 :: Rate this Message:

| View Threaded | Show Only this Message

On 24 May 2012 03:02, Christopher Sigman wrote:
> Any help you can give would be appreciated, and if my super
> simplification is overly so, let me know and I can give it in more
> detail.

The most basic information is missing:  which version of GCC are you using?

It also helps if you provide a minimal, complete example that can be
compiled and demonstrates the problem.  The code you showed doesn't
compile and even when fixed doesn't warn.

Re: Warning message with usage of visibility hidden with wrapper class

by Christopher Sigman :: Rate this Message:

| View Threaded | Show Only this Message

Hi everyone,

Attached is some example code that exhibits the issue.  In terms of
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
add -fvisibility=hidden to compilation of anything linking to the
library resolves the warning, 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).

Thanks for the help,
--
Christopher Sigman



On Wed, May 23, 2012 at 10:02 PM, Christopher Sigman
<c.s.sigman@...> wrote:

>
> Hi all,
>
> My team at work and I have started to utilize the visibility
> attributes in gcc so that we are building 'nix libraries whose public
> symbols are in-line with our Windows builds. With some of our code
> though, we're noticing warnings about parts being declared with
> greater visibility.  As far as we've been able to determine, there's
> nothing being executed incorrectly, but we'd like to understand the
> warning before ignoring it.
>
> The code in question is basically set up like this:
>
> class __attribute__ ((visibility ("hidden"))) SomeClass
> {
>   ...
> }
>
> template <T>
> class WrappingSomeClass
> {
> ...
>   void someFunc()
>   {
>     SomeClass var;
>     ...
>   }
> ...
> }
>
> Where the warning occurs on usage of SomeClass in WrappingSomeClass.
> Any code using this example links to the library with SomeClass in it.
> Any help you can give would be appreciated, and if my super
> simplification is overly so, let me know and I can give it in more
> detail.
>
> --
> CSS


Visibility.tgz (1K) Download Attachment

Re: Warning message with usage of visibility hidden with wrapper class

by Jonathan Wakely-4 :: Rate this Message:

| View Threaded | Show Only this Message

On 31 May 2012 02:42, Christopher Sigman <c.s.sigman@...> 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.