[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [libcvd-members] gvars3 configure gvars...

From: Edward Rosten
Subject: Re: [libcvd-members] gvars3 configure gvars...
Date: Wed, 20 Feb 2008 15:40:52 -0700 (MST)

On Wed, 20 Feb 2008, Ethan Eade wrote:

GVars2 had no globals defined in the library, so that you could define
them in, in the order they need. Wherever they live, all
inter-dependent globals should live in one translation unit, and
that's what you've done in gvars3's, but it doesn't work
(portably) when I have other global classes which call GUI in their
You can always use the template trick, which requires the linker to
ensure that only one instance is created:
// code in a header:
template <int DUMMY=0> struct HoldsGlobal {
   double global;

template <int DUMMY> double HoldsGlobal::global = 3.14;
//end code

Then you use HoldsGlobal<>::global.  The linker is required to treat it
as a weak symbol -- i.e., there will be exactly one instance common to
all translation units when linked.

The other problem is the order of calling global constructors. The standard is rather unhelpful about this.

I don't use any of the widget sets! I suspect there's probably a lot
of stuff which no-one uses anymore in there. For example, IIRC
headless was requested by Ethan, but I think he uses his own thing now
instead of gvars?
I just use a wrapper around GVars2 (I've never installed GVars3) and I
still have to link against libreadline, but schmeh.

Have you tried Gvars3? It's pretty much backwards compatible. I think the majority of code in the library is still unmodified GVars2 code (GUI_Motif, GUI_Fltk (until yesterday), GUI_Fltk2, and quite large chunks of GUI).

The database is now a singleton, though. I seem to remember that the trick I used to make it a singleton came from you originally, but I might have remembered that incorrectly. It uses a static member variable and relies on the linker to eliminate duplicates.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]