Note: This is cross-posted from mcuoneclipse.com for clarity on Linux installation steps. I recommend that you read that post instead if you are a windows user.
Why cppcheck [a static code analyzer] ?
Because we hate manual bug hunting in code which could be a nasty experience. Cppcheck helps automate bug hunting in your code and just point you to some changes you may want to make for a more stable firmware/software. I plan to be using this for embedded development, its my main thing right now.
From the documentation introduction part:
Cppcheck is an analysis tool for C/C++ code. Unlike C/C++ compilers and many other analysis tools, it doesn’t detect syntax errors. Cppcheck only detects the types of bugs that the compilers normally fail to detect. The goal is no false positives.
Read the full documentation online
I did this installation on Ubuntu 14.04 machine.
1. Get cppcheck sources, extract and cd into that directory. Check for latest version here: on the sourceforge files page
wget http://sourceforge.net/projects/cppcheck/files/cppcheck/1.69/cppcheck-1.69.tar.gz && tar -xf cppcheck-1.69.tar.gz && cd cppcheck-1.69/
2. Build cppcheck with some settings using make
make -j 4 SRCDIR=build CFGDIR=/usr/local/share/cppcheck/cfg HAVE_RULES=yes
4. Install cppcheck in your system under /usr/local/bin/ and the configurations in the corresponding share directory under /usr/local/
sudo make PREFIX=/usr/local CFGDIR=/usr/local/share/cppcheck/cfg install
5. Test run: cd into a folder that has C code and run cppcheck
6. Install the cppcheck eclipse plugin. Use eclipse’s Help->Install New Software menu with the update site: http://cppcheclipse.eclipselabs.org.codespot.com/svn/update/
7. Enjoy 🙂