
On 6/9/06, Arkadiy Vertleyb <vertleyb@hotmail.com> wrote:
"Peder Holt" <peder.holt@gmail.com> wrote
I tried compiling the test battery on VC8 with precompiled headers enabled (\Yc with test.hpp as the precompiled header) and encountered similar problems. Eliminating the anonymous namespaces solves the problem, and doesn't introduce any obvious new problems. Is there more than a theoretical reason for the anonymous namespaces in the first place? Is there any observed cases where not having anonymous namespaces causes corruption to typeof?
There are no observed cases, AFAIK.
However, there is also not a lot of experience. ODR is definitely violated, one way or another. Compilers don't seem to complain about our ODR test, but this test is designed for anonymous namespaces. I can also imagine that some compilers may report ODR violation only in certain context. And we never know what new [versions of] compilers will do.
It's easy to make the usage of anonymous namespace configurable by introducing something like BOOST_TYPEOF_SUPRESS_UNNAMED_NAMESPACE. I would also add another ODR test, targeted to this mode.
Having two possibilities may give a better chance of avoiding potential issues with ODR. And having the mode without unnamed namespace would also allow the user to completely avoid ODR by always registering in the same order (having system-wide registration header), although at the expence of dependency bottleneck.
Does this make sence?
Makes sense. A good test then would be: File 1 #include <boost/typeof.hpp> #include <type_registration1.hpp> #include <type_registration2.hpp> Use TYPEOF on types registered in type_registrationx.hpp File 2 #include <boost/typeof.hpp> #include <type_registration2.hpp> #include <type_registration1.hpp> Use TYPEOF on types registered in type_registrationx.hpp We should probably disable anonymous namespaces by default when using precompiled headers. Is there a #define to check if precompiled headers is used? Regards, Peder
Regards, Arkadiy
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost