This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/46097] Switch to warn of global variables in a C++ shared object
- From: "noloader at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 22 Oct 2010 01:59:45 +0000
- Subject: [Bug c++/46097] Switch to warn of global variables in a C++ shared object
- Auto-submitted: auto-generated
- References: <bug-46097-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46097
--- Comment #24 from Jeffrey Walton <noloader at gmail dot com> 2010-10-22 01:59:34 UTC ---
Hi Jonathan,
(In reply to comment #16)
> (In reply to comment #13)
> >
> > [SNIP]
>
> There are a number of options for making sure the global is private to the
> library, thus avoiding multiple definitions of the same object when two copies
> of the code are linked to.
>
> ...
>
> * You can put it in an anonymous namespace.
Would namespaces be via dlmopen? (I've been trying to figure out how a c++
namespace could help, but I think I went down a rabbit hole).
http://linux.die.net/include/dlfcn.h:
/* Like `dlopen', but request object to be allocated in a new namespace. */
extern void *dlmopen (Lmid_t __nsid, __const char *__file, int __mode);
Jeff