Boost logo

Boost-Build :

From: Rene Rivera (grafik666_at_[hidden])
Date: 2002-10-22 10:54:42


[2002-10-22] Patrick Frants wrote:

>Vladimir Prus <ghost_at_[hidden]> wrote in news:3DB525FA.9070404_at_[hidden]:
>
>> Patrick Frants wrote:
>>>
>>> We are reluctant to use libraries because then we need to add an
>>> initialization function to every .cpp to initialize all c++ static
>>> objects... Also it increases total build time.
>>
>> I don't understand what you say here, sorry. Why to you need to add
>> 'initialization' functions? Especially to *every* .cpp?
>
>Paragraph 3.6.2 of the C++ standard says:
>
>"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. If the
>initialization is deferred to some point
>in time after 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) [Example:
...
>Quite often we use static objects that register themselves during
>initialization with a singleton.
...
>One way to be sure that they get constructed is by calling functions within
>each file containing a static object before calling code that relies on
>those statics.
>
>We have found that msvc and gcc initialize all static objects within object
>files that are linked directly. Object files within libraries get
>initialized when a function within that object files is called.

A few things...

1. When you say "libraries" what are you refering to, object archives
(*.lib, *.a, etc), or shared objects (*.dll, *.so, etc)?

2. From your description... wouldn't you have the problem of "implementation
defined" behaviour for any translation unit regardless of it being in an
object file or library file of some sort?

3. Given that you are attempting to link large numbers of object files
directly (as I understand your original problems), why not use an object
archive to collect some of those files? "lib" in Boost.Build terms.

-- grafik - Don't Assume Anything
-- rrivera_at_[hidden] - grafik_at_[hidden]
-- 102708583_at_icq - Grafik666_at_AIM - Grafik_at_[hidden]

 


Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk