[Test] BOOST_CHECK_EQUAL and static const integral members

Hi, BOOST_CHECK_EQUAL is implemented in a way that checking static const integral members yields "undefined reference" errors in GCC. For example -- #define BOOST_TEST_MAIN #include "boost/test/included/unit_test.hpp" struct Test { static const int n = 1; }; BOOST_AUTO_TEST_SUITE(TestSuite); BOOST_AUTO_TEST_CASE(TestCase) { BOOST_CHECK_EQUAL(1,Test::n); } BOOST_AUTO_TEST_SUITE_END(); -- doesn't link in GCC. Is there an easy way to modify BOOST_CHECK_EQUAL in order to avoid this problem? Thanks in advance for any hints. Regards, Stephan

On Sat, 26 Aug 2006 14:00:13 +0200, Stephan Tolksdorf <andorxor@gmx.de> wrote:
Hi,
BOOST_CHECK_EQUAL is implemented in a way that checking static const integral members yields "undefined reference" errors in GCC. For example
-- #define BOOST_TEST_MAIN #include "boost/test/included/unit_test.hpp"
struct Test { static const int n = 1; };
BOOST_AUTO_TEST_SUITE(TestSuite); BOOST_AUTO_TEST_CASE(TestCase) { BOOST_CHECK_EQUAL(1,Test::n); } BOOST_AUTO_TEST_SUITE_END();
One could "fix" BOOST_CHECK_EQUAL, but the problem remains that such static const definitions easily lead to undefined behavior in the current language. If you want I can send you the solution I use in my own code, but I only release it under the GPL. -- [ Gennaro Prota. C++ developer, Library designer. ] [ For Hire http://gennaro-prota.50webs.com/ ]
participants (2)
-
Gennaro Prota
-
Stephan Tolksdorf