Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2005-01-13 13:00:23


Gennadiy Rozental wrote:
> "Jody Hagins" <jody-boost-011304_at_[hidden]> wrote in message
> news:20050113121604.1f0f6ed0.jody-boost-011304_at_atdesk.com...
>>
>> Consider this simple example...
>>
>>
>> #include <boost/test/test_tools.hpp>
>>
>> struct Foo
>> {
>> static unsigned int const x = 10;
>> };
>>
>> int test_main( int, char* [] ) // note the name!
>> {
>> BOOST_CHECK_EQUAL(10U, Foo::x);
>> return 0;
>> }
>>
>>
>>
>> At least under gcc, I get a linker error, unable to find Foo::x,
>> while the following code works fine...
>>
>>
>> int test_main( int, char* [] ) // note the name!
>> {
>> BOOST_CHECK(10U == Foo::x);
>> return 0;
>> }
>
> I remember very similar issue with MPL constants. I consider this a
> compiler bug and it could (and should) be workaround on struct Foo
> implementation level (did you try to use enum?)

The compiler may be right (but I'm not up to date with the latest progress
on the core issues). Foo::x is not defined.

    unsigned int const Foo::x; // in Foo.cpp

should fix it.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk