|
Boost-Build : |
From: Patrick Frants (gclbb-jamboost_at_[hidden])
Date: 2002-10-22 05:55:33
Vladimir Prus <ghost_at_[hidden]> wrote in news:3DB525FA.9070404_at_[hidden]:
> Patrick Frants wrote:
>
>>>in the g++ command-line. But this is a hack that I wouldn't want to
>>>try. What are you trying to accomplish? Linux doesn't have a
>>>command-line length limitation, which is the reason you normally need
>>>response files under Windows.
>>
>>
>> It does have a limitation: MAX_ARG_PAGES(32 by default) * 4096 = 128k
>> for the arguments of a process. I could not believe my ears when I
>> heard about it... Almost makes me consider contributing a patch to
>> Linux, but considering the fact that it is not already there it is
>> probably not that easy... So the easy way out is to recompile the
>> kernel
>>
>> 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:
// File 1
#include "a.h"
#include "b.h"
B b;
A::A(){
b.Use();
}
// File 2
#include "a.h"
A a;
// File 3
#include "a.h"
#include "b.h"
extern A a;
extern B b;
int main() {
a.Use();
b.Use();
}
It is implementation-defined whether either a or b is initialized before
main is entered or whether the
initializations are delayed until a is first used in main. In particular,
if a is initialized before main is
entered, it is not guaranteed that b will be initialized before it is used
by the initialization of a, that is,
before A::A is called. If, however, a is initialized at some point after
the first statement of main, b will
be initialized prior to its use in A::A. ]"
Quite often we use static objects that register themselves during
initialization with a singleton. For example a bunch of static objects
register themselves as GraphicFileFormatReader objects with a singleton.
Now you can add new file formats without changing the code of the
singleton. It is essential however that the static objects get constructed
when the system starts up, preferably before entering main().
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.
Patrick
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