Artful Bytes

A blog about building and programming hardware.

Static Analysis for C/C++ with cppcheck (+Makefile)

October 02, 2022 1 min read

Another video in my project series.

I demonstrate cppcheck, which is a static analyser for C/C++. I show how to enable and suppress errors, and create a Makefile-rule that lets me run "make cppcheck" from the command-line to check my entire project.

This is the repository that I commit to in the video series.

Example 1:

cppcheck --quiet --enable=all --error-exitcode=1 main.c file1.c src/ -I include/

Example 2 (suppress specific error):

cppcheck --quiet --enable=all --error-exitcode=1 --suppress=unusedFunction:main.c:1