Reputation: 43
I have a problem getting BOOST_STATIC_ASSERT_MSG to issue a meaningful error message. I have boiled it down to this:
#include <boost/static_assert.hpp>
namespace StaticChecks
{
BOOST_STATIC_ASSERT_MSG( false, "Where is my error message?" );
}
The specified error message is nowhere to be seen. Instead I get the following:
c:\tryit> x86_64-w64-mingw32-g++ -O0 -g -m64 -Wall -IC:\boost_1_50_0 -IC:\MinGW-W64\msys\include compiletimechecks.cpp -c -o compiletimechecks.cpp.o
compiletimechecks.cpp:5:5: error: invalid application of 'sizeof' to incomplete type 'boost::STATIC_ASSERTION_FAILURE<false>'
compiletimechecks.cpp:5:5: error: template argument 1 is invalid
compiletimechecks.cpp:5:63: error: invalid type in declaration before ';' token
I'm on Windows 7 and using GCC/C++ 64-bit:
c:\tryit> x86_64-w64-mingw32-g++ --version
x86_64-w64-mingw32-g++ (Built by MinGW-builds project) 4.7.2
I get the same error on Linux (Ubuntu 12.04 LTS 64 bit) using gcc version 4.6.3 and Boost version 1.48.
Also, I should add that when the assertion succeeds, it works as expected.
Upvotes: 4
Views: 2259
Reputation: 171167
From the docs on BOOST_STATIC_ASSERT_MSG
:
If the C++0x static_assert feature is not available,
BOOST_STATIC_ASSERT_MSG(x, msg)
will be treated asBOOST_STATIC_ASSERT(x)
.
You're apparently building without -std=c++0x
, so static_assert
is not available and the message is thus not displayed.
Upvotes: 3