Sunday, December 15, 2013

Eclipse, CDT and the codan syntax checker

I have been using eclipse CDT recently on a legacy C++ project and it took a while for me to get the codan syntax checker to work. When it wasn't working it gave syntax errors for things that weren't syntax errors and claimed it couldn't find standard headers like stdlib.h, string.h etc. Use this command to invoke the GNU compiler so that it tells you where it is looking for includes:
g++ -E -x c++ - -v < /dev/null
These are the include directories that need to be configured. I got this tip from StackOverflow at http://stackoverflow.com/questions/11946294/dump-include-paths-from-g

You need to turn on full tracing when invoking eclipse (as explain my earlier post), then you will see if all the paths are resolved or not.

There are lots of posts of how to solve the codan problem but they are tend to be superficial and dismissive, often saying things like "put /usr/include" in the path. That is not good enough, you have to put in all the paths that the compiler uses, including the internal ones. Don't forget that when using cygwin and codan that the paths will have to be DOS-like, i.e. starting with the C:/cygwinDir..blahBlah.

No comments: