public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Warning message with usage of visibility hidden with wrapper class
@ 2012-05-24  2:02 Christopher Sigman
  2012-05-24 10:05 ` Jonathan Wakely
  2012-05-31  1:42 ` Christopher Sigman
  0 siblings, 2 replies; 4+ messages in thread
From: Christopher Sigman @ 2012-05-24  2:02 UTC (permalink / raw)
  To: gcc-help

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Warning message with usage of visibility hidden with wrapper class
  2012-05-24  2:02 Warning message with usage of visibility hidden with wrapper class Christopher Sigman
@ 2012-05-24 10:05 ` Jonathan Wakely
  2012-05-31  1:42 ` Christopher Sigman
  1 sibling, 0 replies; 4+ messages in thread
From: Jonathan Wakely @ 2012-05-24 10:05 UTC (permalink / raw)
  To: Christopher Sigman; +Cc: gcc-help

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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Warning message with usage of visibility hidden with wrapper class
  2012-05-24  2:02 Warning message with usage of visibility hidden with wrapper class Christopher Sigman
  2012-05-24 10:05 ` Jonathan Wakely
@ 2012-05-31  1:42 ` Christopher Sigman
  2012-05-31  9:03   ` Jonathan Wakely
  1 sibling, 1 reply; 4+ messages in thread
From: Christopher Sigman @ 2012-05-31  1:42 UTC (permalink / raw)
  To: gcc-help

[-- Attachment #1: Type: text/plain, Size: 1750 bytes --]

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@gmail.com> 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

[-- Attachment #2: Visibility.tgz --]
[-- Type: application/x-gzip, Size: 742 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Warning message with usage of visibility hidden with wrapper class
  2012-05-31  1:42 ` Christopher Sigman
@ 2012-05-31  9:03   ` Jonathan Wakely
  0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Wakely @ 2012-05-31  9:03 UTC (permalink / raw)
  To: Christopher Sigman; +Cc: gcc-help

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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-05-31  9:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-24  2:02 Warning message with usage of visibility hidden with wrapper class Christopher Sigman
2012-05-24 10:05 ` Jonathan Wakely
2012-05-31  1:42 ` Christopher Sigman
2012-05-31  9:03   ` Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).