Singleton instantiated more than once with -fvisibility=hidden

Filipe Sousa filipe@ipb.pt
Fri Jun 3 14:20:00 GMT 2005


On Friday 03 June 2005 15:09, Mws wrote:
> On Friday 03 June 2005 15:45, Filipe Sousa wrote:
> > On Friday 03 June 2005 14:22, Mws wrote:
> > > template<class IMPLEMENTINGCLASS>
> > > class TSingleton
> > > {
> > >         private:
> > >                 static IMPLEMENTINGCLASS* instance;
> > >
> > >         public:
> > >                 static IMPLEMENTINGCLASS* getInstance()
> > >                 {
> > >                         //debugging purposes
> > >                         std::cout << "before" << instance << std::endl;
> > >                         if(!instance)
> > >                         {
> > >                                 instance = new IMPLEMENTINGCLASS();
> > >                         }
> > >                         std::cout << "after" << instance << std::endl;
> > >                         return instance;
> > >                 }
> > >
> > >                 void dispose()
> > >                 {
> > >                         if(instance)
> > >                         {
> > >                                 delete instance;
> > >                                 instance = NULL;
> > >                         }
> > >                 }
> > > };
> > >
> > > template<class IMPLEMENTINGCLASS> IMPLEMENTINGCLASS*
> > > TSingleton<IMPLEMENTINGCLASS>::instance = NULL;
> >
> > But I still have more then one instance:
> >
> > before0
> > my_singleton::my_singleton()
> > after0x804a008
> > before0
> > my_singleton::my_singleton()
> > after0x804a018
>
> what?
> show me your main please
>
> regards
> mws

-- 
Filipe Sousa
-------------- next part --------------
A non-text attachment was scrubbed...
Name: main.cc
Type: text/x-c++src
Size: 104 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-help/attachments/20050603/538ad2bd/attachment-0004.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: singleton.h
Type: text/x-c++hdr
Size: 932 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-help/attachments/20050603/538ad2bd/attachment-0005.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: singleton.cc
Type: text/x-c++src
Size: 80 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-help/attachments/20050603/538ad2bd/attachment-0006.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Makefile
Type: text/x-makefile
Size: 372 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-help/attachments/20050603/538ad2bd/attachment-0007.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-help/attachments/20050603/538ad2bd/attachment-0001.sig>


More information about the Gcc-help mailing list