[Top][All Lists]

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

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

From: Ethan Eade
Subject: Re: [libcvd-members] gvars3 configure gvars...
Date: Wed, 20 Feb 2008 22:24:48 +0000
User-agent: Thunderbird (X11/20070801)

> 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
> constructors.
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.

> (Shrug)
> 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.

- Ethan

reply via email to

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