Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #14759

Re: globals from lib accessed by other libs

From Mike McCarty <mcmccarty@gmail.com>
Newsgroups comp.lang.c++
Subject Re: globals from lib accessed by other libs
Date 2012-03-05 09:56 -0800
Organization http://groups.google.com
Message-ID <3710870.775.1330970199751.JavaMail.geo-discussion-forums@vbcu2> (permalink)
References <22758150.210.1330964696511.JavaMail.geo-discussion-forums@vbcv2>

Show all headers | View raw


On Monday, March 5, 2012 10:24:56 AM UTC-6, Christopher wrote:
> Is this a bad idea? I think it is. However, I am having a bit of trouble explaining why.
> 
> I generally frown on globals in the first place, but this seems even worse. Sharing a global from one library with other libraries?

Beyond the usual caveats concerning global variables, an additional problem here is that Lib2 will probably be unloaded before Lib1 at app shutdown.  This leaves pA pointing at a destroyed object (since the instance was allocated statically) for some indeterminate span of time.  All someone has to do is call SomeOtherMethod() at the wrong time and *kaboom*.  

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

globals from lib accessed by other libs Christopher <cpisz@austin.rr.com> - 2012-03-05 08:24 -0800
  Re: globals from lib accessed by other libs Victor Bazarov <v.bazarov@comcast.invalid> - 2012-03-05 12:03 -0500
  Re: globals from lib accessed by other libs Mike McCarty <mcmccarty@gmail.com> - 2012-03-05 09:56 -0800
    Re: globals from lib accessed by other libs Jorgen Grahn <grahn+nntp@snipabacken.se> - 2012-03-07 13:16 +0000
      Re: globals from lib accessed by other libs BGB <cr88192@hotmail.com> - 2012-03-08 09:39 -0700
  Re: globals from lib accessed by other libs BGB <cr88192@hotmail.com> - 2012-03-05 11:16 -0700

csiph-web