$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2006-12-15 19:20:52
>> It seems to me that on non-metrowerks compilers it simply defines a
>> namespace-scope const reference object, in a nameless
>> namespace. This means that the reference is guaranteed to be
>> initialized only if you execute a function in the compilation unit
>> that includes export.hpp. So again, you're at the mercy of the
>> optimizer to not deadstrip this code.
>
> It is not allowed to deadstrip the code if any other code in the
> translation unit gets used, because the object must be initialized
> before the first use of any object or function in the TU.
Right, but as far as I can see, the whole point of this automatic
registration is that it happens just because you link a particular object
file that includes the serialization library and uses the registration
macros, without a need to explicitly call a function defined in it.
>> I don't have access to Metrowerks right now but I suspect that this has
>> nothing to do with initializing static members of class templates.
>
> I think you're wrong; I was pretty careful in my analysis.
>
>> If I correctly recall my experience from about 2 years ago,
>> Metrowers simply deadstrips the entire compilation unit, functions,
>> global objects -- everything -- simply because it figures that
>> nothing calls this code, and this has nothing to do with
>> templates. I believe that this is correct, standard-complying
>> behavior.
>
> Yes, it is standard conforming to deadstrip the TU if nothing calls
> the code, and yes, Metrowerks is really good at making that
> optimization, but no, that's not what the comment is referring to.
> There really is a compiler bug IIRC.
Ah I understand. Right, so it's a different issue altogether, but the
automatic registration is still not portable.
Or did I completely misunderstand the documentation? Robert, was the
intended meaning that *if* you explicitly call a function from foo.cpp, then
using the class export macro guarantees that class foo is properly
registered with the serialization library?