Boost logo

Boost Users :

From: Gennadiy Rozental (gennadiy.rozental_at_[hidden])
Date: 2007-05-23 12:55:36


> "Kolya" <wxkolya_at_[hidden]> wrote in message
> news:1f5259800705230242hb812523mc864b34c6d35e145_at_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_at_unit_test_at_boost@@3AAVunit_test_log_t_at_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(); }

HTH,

Gennadiy


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