Boost logo

Boost Users :

From: Kolya (wxkolya_at_[hidden])
Date: 2007-05-23 05:42:48


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_at_unit_test_at_boost@@3AAVunit_test_log_t_at_23@A)
already defined in file2.obj

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(); }

When I replace

BOOST_TEST_SINGLETON_INST( unit_test_log )

in boost/test/unit_test_log.hpp with

namespace {extern unit_test_log_t & unit_test_log;}

and in one of my cpp-files add:

namespace boost
{
    namespace unit_test
    {
        BOOST_TEST_SINGLETON_INST( unit_test_log )
    }
}

all works fine

May be I do not understand something?
Is there any legal workaround from this situation? I do not like touch boost
core files by myself.

Thank you!

VC++ 7.1, boost 1.34, xp sp2.



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net