libcvd-members
[Top][All Lists]
Advanced

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

Re: [libcvd-members] gvars3 Makefile.in configure configure.ac gvars...


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

>> 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;
Should read "static 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.
Yes, trickier.







reply via email to

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