You can analyze code quickly without creating a project file. This is useful to try Cppcheck, or to look at a few files. For regular use a project is better: with a properly configured project Cppcheck knows your include paths, defines and libraries, and the analysis is more accurate. You also get features that need a project, such as saved suppressions, tags and the build dir. See Project files.
If a project is open, close it first with File > Close Project File. The GUI does not let you analyze files or folders while a project is open.
Select Analyze > Files... (Ctrl+F) and select one or more source files. The analysis starts at once.
In the same file dialog you can also select a project of your build system. Cppcheck then analyzes the files of that project with its include paths and defines, just as if you had imported it in a project file:
compile_commands.json),*.sln, *.slnx) or
project (*.vcxproj). For a solution, a dialog asks which
configuration (for example Debug|x64) to analyze,*.bpr).Select Analyze > Directory... (Ctrl+D) and select a folder.
Cppcheck analyzes all source files in the folder and its subfolders. Files
with these extensions are analyzed: .c, .cpp,
.cxx, .cc, .c++, .tpp,
.txx, .ipp and .ixx.
Header files are not analyzed on their own. The code in a header is analyzed when a source file includes it, as long as Cppcheck can find the header.
If the folder contains a Cppcheck project file, the GUI asks if you want to open that project instead. If there are several project files, it asks if you want to continue without them.
Without a project, the analysis uses:
The Analyze menu settings are remembered when you close the GUI.
Analyze > C standard and Analyze > C++ standard select the language version. It affects how some code is parsed and which checks apply. For example, some functions are deprecated in newer standards, and some library functions only exist in newer standards.
With Auto-detect language the file extension decides if a file is C or C++. Choose Enforce C or Enforce C++ to treat all files as one language.
The platform decides the size of the basic types (short,
int, long, pointers, wchar_t and so on)
and whether char is signed. Choose the platform the code will run
on:
TCHAR and _tcscpy mean the char
versions; in the Unicode variant they mean the wchar_t
versions.Without a project:
After you change the code, use Analyze > Reanalyze modified files (Ctrl+R) to analyze the files that changed, or Reanalyze all files to analyze everything again.