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


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

globals from lib accessed by other libs

From Christopher <cpisz@austin.rr.com>
Newsgroups comp.lang.c++
Subject globals from lib accessed by other libs
Date 2012-03-05 08:24 -0800
Organization http://groups.google.com
Message-ID <22758150.210.1330964696511.JavaMail.geo-discussion-forums@vbcv2> (permalink)

Show all headers | View raw


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?

Every 3rd Party lib I've used doesn't do this.

-----
In Lib 1, In A.H:

class A
{
   // Various methods and data
};

extern A * pA;

-----
In Lib 1, In A.cpp:
A * pA = NULL;

-----

In Lib 2, in something.cpp:
#include "A.h"

A a;

void SomeMethod()
{
   pA = &a;
}

-----
In Lib 3, in someother.cpp

void SomeOtherMethod()
{
   pA->DoStuff();
}

Back to comp.lang.c++ | Previous | Next — 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