Recently I read a post at Facebook Code about flint - yet another C++ linter. I though I could run this on our project to see whether it will outperform CppCheck. It was pain in the ass to compile this stuff. I hope this post will save your time, if you encounter similar problems.
folly
Folly is a C++ library used at Facebook. You can find details here. Without digging in one can discover that compilation instructions aren't descriptive enough. If you are running on Fedora 17 or Ubuntu 12.10 everything should compile as expected. Otherwise you have to pay attention which version of libraries folly depends on you download.
The first dependency is double-conversion. In the instructions it is said that if you have scons, you have double-conversion. This was not true in my case. I had to manually download it. I picked version 1.1.5, and apparently this is not the best one to pick. It doesn't compile at straight off. To make it working one must create symbolic magic link.
ln -s <double-conversion>/src/libdouble_conversion_pic.a <double-conversion>/src/libdouble-conversion.a
This is not the only link needed. The second one concerns header files.
ln -s <double-conversion>/src/ <double-conversion>/src/double-conversion
Now the compilation should go further. The next issue that occurred in my system was related to Google->opensource. Somehow I downloaded opensourced Gflags library, but the folly was still referring to Google one. Following one-liner helped to resolve this issue.
find . -name "*.cpp" -print | xargs sed -i 's/google::ParseCommandLineFlags/gflags::ParseCommandLineFlags/g'
flint
Here you should be prepared to install newer version of dmd, gdc, or ldc. Above find-replace command is also needed. The one thing that is wrong on flint GitHub page is missing dot after -L.
This way the executable comes, but running it gives segmentation fault. I figured out that CXX executable is working fine and it gives reasonable output. The D version seem to be broken.
If time permits I'll try to dig in and examine why. As always, you are welcome to share your ideas in comments.
Flint output looks very clear. In our project it found several problems, mainly related to non-explicit constructors, that may be accidentally treated as conversion constructors. Also, it was able to find header files without include guards (nice one!).
The last interesting that caught my eye is the following. It refers to SO ;)
/home/szborows/****.hpp(12): Warning: Protected inheritance is sometimes not a good idea. Read http://stackoverflow.com/questions/6484306/effective-c-discouraging-protected-inheritance for more information.
Update (10.06.2014, 01:32):
I managed to create valid D executable of flint through manually compiling newest version of dmd compiler and using it against flint.
There is no difference in output.
Great Post.
OdpowiedzUsuńC &C++ course in Pune