"Kolya" <wxkolya@gmail.com> wrote in message
news:1f5259800705230242hb812523mc864b34c6d35e145@mail.gmail.com...
Hi, All!
I am using Boost.Test library in my own application and I have included
boost/test/unit_test.hpp in many my cpp-files.
When I used boost version 1.33.1 all works fine. But in version 1.34 I
have following compiler error:
file1.obj : error LNK2005: "class unit_test_log_t::boost::unit_test_log_t
& boost::unit_test::`anonymous namespace'::unit_test_log"
(?unit_test_log@?
A0xa35d3712@unit_test@boost@@3AAVunit_test_log_t@23 @A) already defined in
file2.obj
Looks liek clear compiler bug. Anounimus namespace is used specifically to
avoid duplicate symbols.
After including boost/test/unit_test.hpp class unit_test_log has multiple
instances.
See boost/test/unit_test_log.hpp for details:
BOOST_TEST_SINGLETON_INST( unit_test_log )
It means that following code will be included in many cpp-files!
namespace { unit_test_log_t & inst = unit_test_log_t::instance(); }
Try adding static. Though it's like saying the same twice.
namespace { static unit_test_log_t & inst = unit_test_log_t::instance(); }