public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "bkoz at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/21764] visibility attributes on namespace scope
Date: Fri, 04 Nov 2005 17:05:00 -0000	[thread overview]
Message-ID: <20051104170551.30559.qmail@sourceware.org> (raw)
In-Reply-To: <bug-21764-365@http.gcc.gnu.org/bugzilla/>



------- Comment #5 from bkoz at gcc dot gnu dot org  2005-11-04 17:05 -------
In addition to the current ability to put visibility attributes on file and
class scope, the ability to put visibility attributes on namespace scope is
desired.

The syntax is straight forward extension of existing visibility attribute
options.

namespace test __attribute__ ((visibility("hidden")))
{
  struct c1 
  {
    static int s;
    virtual void foo() { }
  };

  int c1::s;
}

Is an example.

What does this mean? For definitions within namespace scope, set the symbol
visibility to the nearest enclosing namespace attribute. Declarations are
unaffected.

Nested namespaces have the same semantics as nested classes. Ie, enclosing
scope. Therefore:

#define VIS_default __attribute__ ((visibility("default")))
#define VIS_hidden __attribute__ ((visibility("hidden")))

  struct c1 
  {
    static int s;
    virtual void foo() { }

    struct c2 
    {
      static int s;
      virtual void foo() { }
    } VIS_default;
  } VIS_hidden;

namespace test1 VIS_hidden
{
  struct c1 
  {
    static int s;
    virtual void foo() { }
  };

  int c1::s;

  namespace test2 VIS_default
  {
    struct c2 
    {
      static int s;
      virtual void foo() { }
    };

    int c2::s;
  }
}

In the above, struct c2 and test1::test2::c2 both have default visibility,
whereas c1 and test1::c1 both have hidden visibility.

Interactions between file, namespace, and class scope are handled sanely. Ie,
the same deal, nearest enclosing scope.

ie:

#pragma GCC visibility push(hidden)

namespace test1 VIS_default
{
  struct c1 
  {
    static int s;
    virtual void foo() { }
  };

  int c1::s;

  struct c2 
  {
    static int s;
    virtual void foo() { }
  } VIS_hidden;

  int c2::s;
}

#pragma GCC visibility pop

In the above, c1 would be default, c2 would be hidden.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21764


  parent reply	other threads:[~2005-11-04 17:05 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-21764-365@http.gcc.gnu.org/bugzilla/>
2005-11-04 13:05 ` pinskia at gcc dot gnu dot org
2005-11-04 17:05 ` bkoz at gcc dot gnu dot org [this message]
2005-11-17 22:55 ` jason at gcc dot gnu dot org
2005-11-17 23:53 ` bkoz at gcc dot gnu dot org
2005-11-18  6:15 ` jason at redhat dot com
2005-11-18 19:39 ` geoffk at geoffk dot org
2005-12-02 22:16 ` jason at gcc dot gnu dot org
2005-12-13  6:46 ` jason at gcc dot gnu dot org
2006-03-21  3:19 ` jason at gcc dot gnu dot org
2006-03-21 16:32 ` pinskia at gcc dot gnu dot org
2006-08-28 12:22 ` jakub at gcc dot gnu dot org
2005-05-26  7:32 [Bug c++/21764] New: " bkoz at gcc dot gnu dot org
2005-05-26 12:02 ` [Bug c++/21764] " giovannibajo at libero dot it
2005-05-26 16:04 ` bkoz at gcc dot gnu dot org
2005-05-26 20:12 ` pinskia at gcc dot gnu dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20051104170551.30559.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).