|
Boost Users : |
From: Aleksey Gurtovoy (agurtovoy_at_[hidden])
Date: 2006-12-02 18:51:00
craigp writes:
> For some reason, I can't get the IDE to compile BOOST_MPL_ASSERT. I tried this:
>
> #include <boost/type_traits/is_same.hpp>
> #include <boost/mpl/assert.hpp>
>
> int main()
> {
> BOOST_MPL_ASSERT(( boost::is_same< char, char > ));
> }
>
> and it gives the following errors:
>
> d:\dev\boost.cvs\boost\libs\fusion\example\extension\test_example.cpp(31) :
> error C2143: syntax error : missing ';' before '='
> d:\dev\boost.cvs\boost\libs\fusion\example\extension\test_example.cpp(31) :
> error C2143: syntax error : missing ';' before '='
>
> what's even stranger is that i copied/pasted the pre-processed file, and that
> compiled just fine:
>
> static const std::size_t mpl_assertion_in_line_26 = sizeof(
> boost::mpl::assertion_failed<false>( boost::mpl::assert_arg( (void (*) (
> boost::is_same< char, char > ))0, 1 ) ) );
>
> anyone else seen something like this before?? all the mpl regression tests
> compile fine via bjam (using msvc 7.1), so it appears ide-specific,
> somehow...
This is a known issue: the errors you see are specific to MSVC "Edit &
Continue" mode, in which the __LINE__ macro (used internally in MPL
asserts) stops being a preprosessing-time constant and becomes a
reference to a global run-time variable
(http://support.microsoft.com/kb/199057).
To alleviate this problem, Microsoft has introduced a proprietary
predefined macro __COUNTER__
(http://msdn2.microsoft.com/en-us/library/b0084kay.aspx), intended to
serve as a replacement for __LINE__ in situations where the latter is
used to generate a unique identifier rather than to actually refer to
a line number (which is the case with MPL asserts). Unfortunately,
because __COUNTER__ is incremented every time it's used, fixing this
is a bit more complicated then just a search & replace for __LINE__,
and therefore it has to wait for 1.35 (or you can grab the latest
version of "boost/mpl/assert.hpp" from Boost CVS's HEAD trunk).
HTH,
-- Aleksey Gurtovoy MetaCommunications Engineering
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