Answers to common questions and problems.
There are two kinds:
<stdio.h> or <vector>, was not found.
This is normal. Cppcheck does not need these headers, because it knows the
standard library and the libraries you select in the project. Hide the
information severity, or suppress the id
missingIncludeSystem in the project.Use Analyze > Check configuration (defines, includes) to get a list of the configuration problems of the project.
Cppcheck does not analyze a file it can not parse. A message like There is an unknown macro here somewhere. Configuration is required. means that the code uses a macro that Cppcheck does not know, in a place where the code can not be parsed without knowing what the macro means. For example:
DECLARE_HANDLER(foo) // what is this?
{
...
}
To fix it, do one of these:
Q_OBJECT and signals, or windows for the
Windows API macros),DECLARE_HANDLER(x)=void x(), or in a
library configuration file.If the code is correct and compiles, but Cppcheck still reports a syntax error, please report it as a Cppcheck bug.
/usr/include) to
the include paths.First check the configuration: missing include paths and missing library configurations are common causes. For example, if your code calls a function that never returns and Cppcheck does not know that, it can report problems in code that is never reached. Configure the function as noreturn in a library configuration (see Library editor).
If the configuration is right, suppress the warning (see Hiding and suppressing warnings) and please report the false positive to the Cppcheck project with a small code example. Use the scratchpad to make the example as small as possible.
#ifdef block, it may only be analyzed when a
macro is defined.Cppcheck can not find all bugs. If you think the bug should be found, create a small example in the scratchpad and report it to the Cppcheck project.
Select Analyze > Reanalyze and check library. The project is analyzed again, and Cppcheck reports information messages for functions it has no configuration for, for example:
checkLibraryNoReturn: Cppcheck does not know if the function
can return. Configure noreturn for it.checkLibraryFunction: the function is not configured at all.
If it is a library function, configure it so that Cppcheck can check how it
is used.Write the missing configuration in a .cfg file with the
library editor or a text editor, put it
in the folder of the project file and select it on the Types and
Functions tab of the project.
Install Clang-Tidy (it is part of LLVM/Clang). If it is not in the PATH, set
the Clang path in the preferences to the
folder where clang-tidy is.
No editor is configured, or no default editor is selected. Add your editor on the Applications tab of the preferences and click Set as default. If the editor does not start, check the executable path and the parameters.
When you open a project with a build dir, the results of the last analysis are shown, not a new analysis. Click Reanalyze all files to analyze the current code.
The GUI can not find its data files. The Cppcheck installation is broken;
reinstall Cppcheck. If you built Cppcheck yourself, make sure the
cfg folder is installed next to the program, or configure the data
folder with the --data-dir command line
option.