What you describe here is the opposite of what is stated in the lib.
> I think it is not the same as defining a global static variable.No the fancy trick works. I've seen it used in XSD-tree's code which is
Global
> static variable will have internal linkage and therefore be visible
inside
> the compilation unit where defined only. Between the compilation units
these
> variables will be different.
completly a header only. They put all their globals in a template class
with a single parameter char. MyClass<char>::variable has to be the
same in all compilation scopes. The standard says so. So the linker
has to eliminate duplicate symbols.
Anonymous namespaces in headers are bad; as are declaring things static
> IMO C++ like approach would be to introduce an
> anonymous namespace in header files and define global variables there.
> Defining static vars in the template class will result in a static
variable
> per class template instantiation. Which is not exactly the same, as
intended
> here.
in headers. It makes the compiler generate seperate objects per
compilation scope, which isn't what you want.
The compiler warning is right. If I include this header in 20
compilation scopes I shouldn't have 20 copies of these constants (just
refs) in my binary.
At least the stuff in boost/system/error_code.hpp could easily be moved
to a cxx. Boost::system is not a header only library.
Chris
_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users