eclipse and boost unit_test_framework failing syntax check using c++
i have the following Problem. I started to use the boost library version 1.40, for unit testing. Since some other people working on the project and not all of them are using eclipse, the program has to be compilable with a makefile. So we used cmake to generate one. The good thing is, the test is building and working perfectly fine.
But the problem is, when using eclipse (created a c++ makefile project), it complains about several syntax errors (in the sourcecode view). Something like:
BOOST_AUTO_TEST_CASE( my_test )
{ some code }
will be detected as a syntax error by eclipse. It is really annoying having all these error messages in the IDE. Since after the first line nearly every line in the some code
block is marked as having syntax errors as well.
So here is what i tried already:
- I added `/usr/include/boost/` to the GNU C++ path options. (properties->C/C++ General->Path and Symbols->Path). This works normally for other external libs that are included by FindPkgConfig in the cmake file. So that the auto completion in eclipse can find the correct classes and function names.
- Same way included `/usr/include/boost/test/` directly.
- Adding `/usr/lib/libboost_unit_test_framework.so.1.40.0` to the Libraries list.
- Adding `/usr/lib` to the Library Paths.
So anyone has a hint how to teach 开发者_如何学JAVAeclipse that the syntax of the boost Macros is correct??
Update:
I forgot: System is Linux and Eclipse Version is 3.6.1, CDT Version is: Version: 1.0.0.201009141542 Build id: 201009141542I don't have a solution but maybe a hint. I had a similar setup and it worked perfectly until... the only relevant change I remember is that I changed the name of a test suite. So (probably) after that, the syntax highlighting went crazy. I tried indexing and refreshing but it didn't help. I can't even see the macro expansion because the syntax error prevents it from popping up.
My guess is — still — some indexing issue, because it worked before and I didn't change any include paths. It compiles without problems, but it's urinating these yellow syntax error markers all over the document, which is really, really annoying.
However, it's probably not a path issue because it worked for me before.
I just did this myself using Eclipse Helios, and it does indeed work for me...
Shouldnt you add /usr/include
and not /usr/include/boost
, since boost
is part of the include path used in your program?
For example <boost/unit_test.hpp>
is simply <unit_test.hpp>
if you include the boost folder aswell..
This is what I have added under GNU c++ include directories:
/usr/local/include //this is where I store the boost folder
/usr/include/c++/4.5.2 //This was needed since not even <map>, <vector> etc would resolve in eclipse.
Intellisense and autocompletion for C++ are pretty much impossible to get right in all cases. If the many macros used in Boost.Test confuse Eclipse, then perhaps you should find a cleaner unit test library. I can recommend Catch, which has a cleaner and friendlier syntax, is header-only so it's much easier to set up, and doesn't rely on macros. It is under active development by another SO user.
I had this problem as well (but on a Mac system). Once I added the boost path to GNU C++ path options, I restarted my operating system and Eclipse doesn't tag BOOST_AUTO_TEST_SUITE as an error any more.
精彩评论