Opened 7 years ago
#12135 new Bugs
Boost.Concepts shoudn't create typedefs based on line number
Reported by: | Owned by: | jsiek | |
---|---|---|---|
Milestone: | To Be Determined | Component: | concept_check |
Version: | Boost 1.60.0 | Severity: | Problem |
Keywords: | Compile Error | Cc: |
Description
Hey so today I spent about 30 minutes tearing my hair out over this compile error:
error: typedef redefinition with different types ('instantiate<&::boost::concepts::requirement_<void (*)(concept::Window<qt_window>)>::failed>' vs 'instantiate<&::boost::concepts::requirement_<void (*)(concept::Viewport<qt_viewport>)>::failed>')
This error isn't useful to what was happening. I had two BOOST_CONCEPT_ASSERT((...))s in two different files, under the global namespace. At first I theorized that it wasn't just supported but according to the docs BOOST_CONCEPT_ASSERT can be used in any scope. Then I started to look at the implementation and found this line: BOOST_PP_CAT(boost_concept_check,LINE) which gave it all away: they were both on the same line. The thing is that I use a code formatter, so I actually have to add comments or code to change the line number a line of code is on.
I would love this to be fixed. There is a fine workaround, but it isn't a very easy to find error in your code.
Here is a simple test case. Just add a newline before the BOOST_CONCEPT_ASSERT((...)) in either of the headers to get rid of the error:
Code highlighting:
// a.h #include <boost/concept_check.hpp> BOOST_CONCEPT_ASSERT((boost::Integer<int>)); // note line number
Code highlighting:
// b.h #include <boost/concept_check.hpp> BOOST_CONCEPT_ASSERT((boost::UnsignedInteger<unsigned int>)); // note line number
Code highlighting:
// main.cpp #include "a.h" #incldue "b.h" int main(){}