Subject: Re: C shared lib question
To: None <current-users@netbsd.org>
From: Ingolf Koch <ingolf@jena-optronik.de>
List: current-users
Date: 03/09/2000 10:50:18
On Thu, Mar 09, 2000 at 01:55:05AM -0500, Laine Stump wrote:
> I may be misremembering, but I thought that, while the original C++
> guaranteed execution of constructors for global objects, that they later
> removed that guarantee (and that, as a matter of fact, many implementations
> of C++ don't do it).
Have a look at e.g. section 3.6.2 "Initialization of non-
local objects" in the C++ standard.
"3 It is implementation-defined whether or not the
dynamic initialization (8.5, 9.4, 12.1, 12.6.1)
of an object of namespace scope is done before
the first statement of main, it shall occur before
the first use of any function or object defined
in the same translation unit as the object to be
initialized 31) [...]
31) An object defined in namespace scope having
initialization with side-effects must be
initialized even if it is not used (3.7.1)."
So I think that execution of the constructor is guaranteed
(as long as the object is used) but it is not specified
when exactly the constructor is called.
Regards
Ingolf
--
Ingolf Koch Jena-Optronik GmbH
ingolf@jena-optronik.de ++49 3641 200-147
PGP: 0x7B3B5661 213C 828E 0C92 16B5 05D0 4D5B A324 EC04