|
From: Joe M. <joe...@me...> - 2006-03-01 21:15:26
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Brendan Drew wrote: >> Some portions are, yes. Although I'll admit right now that I'm surprised >> if this were the case. The variables are initialized as they are >> declared. I believe (and please, correct me if I'm wrong) that static >> variables which are initialized in place (e.g. static int foo = 0; ) >> result in the compiler emitting code which has the static variable >> allocated and initialized in the data section (i.e. initialized as the >> program is read into memory). The C++ FAQ says, "static local objects are constructed the first time control flows over their declaration" (http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.12). This is important because it allows the programmer to specify exactly the initialization order. (This only really matters if the initializer is a function call, or otherwise depends on other variables which need initialization.) I assume the compiler's allowed to initialize statics in the data section only if they're initialized with a compile-time constant. Joe -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2.1 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFEBg7jq5NnQEnPdLcRAsTBAJ4lY0W1z1rkEd69Sv5sQ0dJg5mTowCfVjWG yvWKNabIH3D6RN/oGFGYlNw= =WIXa -----END PGP SIGNATURE----- |