Skip to content

Commit

Permalink
manual-premium.md: copy changes from manual.md (danmar#5813)
Browse files Browse the repository at this point in the history
  • Loading branch information
danmar authored Dec 30, 2023
1 parent 24133d4 commit 0c8ee78
Showing 1 changed file with 82 additions and 8 deletions.
90 changes: 82 additions & 8 deletions man/manual-premium.md
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ If you can generate a compile database, then it is possible to import that in Cp

In Linux you can use for instance the `bear` (build ear) utility to generate a compile database from arbitrary build tools:

bear make
bear -- make

# Preprocessor Settings

Expand Down Expand Up @@ -450,10 +450,10 @@ The format for an error suppression is one of:
[error id]:[filename2]
[error id]

The `error id` is the id that you want to suppress. The easiest way to get it is to use the --template=gcc command line flag. The id is shown in brackets.
The `error id` is the id that you want to suppress. The id of a warning is shown in brackets in the normal cppcheck text output. The suppression `error id` may contain \* to match any sequence of tokens.

The filename may include the wildcard characters \* or ?, which matches any sequence of characters or any single character respectively.
It is recommended to use "/" as path separator on all operating systems. The filename must match the filename in the reported warning exactly.
The filename may include the wildcard characters \* or ?, which matches any sequence of characters or any single character respectively.
It is recommended to use forward-slash `/` as path separator on all operating systems. The filename must match the filename in the reported warning exactly.
For instance, if the warning contains a relative path, then the suppression must match that relative path.

## Command line suppression
Expand Down Expand Up @@ -929,13 +929,87 @@ Addons could be run through Cppcheck command line utility as follows:

This will launch all Cppcheck checks and additionally calls specific checks provided by selected addon.

# Library configuration
Some addons need extra arguments. You can configure how you want to execute an addon in a json file. For example put this in misra.json:

{
"script": "misra.py",
"args": [
"--rule-texts=misra.txt"
]
}

And then the configuration can be executed on the Cppcheck command line:

When external libraries are used, such as WinAPI, POSIX, gtk, Qt, etc, Cppcheck doesn't know how the external functions behave. Cppcheck then fails to detect various problems such as memory leaks, buffer overflows, possible null pointer dereferences, etc. But this can be fixed with configuration files.
cppcheck --addon=misra.json somefile.c

Cppcheck already contains configurations for several libraries. They can be loaded as described below. Note that the configuration for the standard libraries of C and C++, std.cfg, is always loaded by cppcheck. If you create or update a configuration file for a popular library, we would appreciate if you upload it to us.
By default Cppcheck would search addon at the standard path which was specified
during the installation process. You also can set this path directly, for example:

cppcheck --addon=/opt/cppcheck/configurations/my_misra.json somefile.c

This allows you to create and manage multiple configuration files for different projects.

# Library configuration

## Using your own custom .cfg file
When external libraries are used, such as WinAPI, POSIX, gtk, Qt, etc, Cppcheck has no information about functions, types, or macros contained in those libraries. Cppcheck then fails to detect various problems in the code, or might even abort the analysis. But this can be fixed by using the appropriate configuration files.

Cppcheck already contains configurations for several libraries. They can be loaded as described below. Note that the configuration for the standard libraries of C and C++, std.cfg, is always loaded by cppcheck. If you create or update a configuration file for a popular library, we would appreciate if you supplied it to the cppcheck project.

## Using a .cfg file

To use a .cfg file shipped with cppcheck, pass the `--library=<lib>` option. The table below shows the currently existing libraries:
| .cfg file | Library | Comment |
| ------------- | ------------- | ------------- |
| avr.cfg | |
| bento4.cfg | [Bento4](http://www.bento4.com/) |
| boost.cfg | [Boost](http://www.boost.org/)|
| bsd.cfg | [BSD](https://www.freebsd.org/) |
| cairo.cfg | [cairo](https://www.cairographics.org/) |
| cppcheck-lib.cfg | [Cppcheck](http://cppcheck.net/) | Used in selfcheck of the Cppcheck code base
| cppunit.cfg | [CppUnit](https://sourceforge.net/projects/cppunit/) |
| dpdk.cfg | |
| embedded_sql.cfg | |
| emscripten.cfg | |
| ginac.cfg | |
| gnu.cfg | [GNU](https://www.gnu.org/) |
| googletest.cfg | [GoogleTest](https://github.com/google/googletest) |
| gtk.cfg | [GTK](https://www.gtk.org/) |
| icu.cfg | |
| kde.cfg | [KDE](https://kde.org/) |
| libcerror.cfg | [libcerror](https://github.com/libyal/libcerror) |
| libcurl.cfg | [libcurl](https://curl.se/libcurl/) |
| libsigc++.cfg | [libsigc++](https://github.com/libsigcplusplus/libsigcplusplus) |
| lua.cfg | |
| mfc.cfg | [MFC](https://learn.microsoft.com/en-us/cpp/mfc/mfc-desktop-applications) |
| microsoft_atl.cfg | [ATL](https://learn.microsoft.com/en-us/cpp/atl/active-template-library-atl-concepts) |
| microsoft_sal.cfg | [SAL annotations](https://learn.microsoft.com/en-us/cpp/c-runtime-library/sal-annotations) |
| microsoft_unittest.cfg | [CppUnitTest](https://learn.microsoft.com/en-us/visualstudio/test/microsoft-visualstudio-testtools-cppunittestframework-api-reference) |
| motif.cfg | |
| nspr.cfg | |
| ntl.cfg | |
| opencv2.cfg | [OpenCV](https://opencv.org/) |
| opengl.cfg | [OpenGL](https://opengl.org/) |
| openmp.cfg | [OpenMP](https://www.openmp.org/) |
| openssl.cfg | [OpenSSL](https://www.openssl.org/) |
| pcre.cfg | [PCRE](https://pcre.org/) |
| posix.cfg | [POSIX](https://pubs.opengroup.org/onlinepubs/9699919799/) |
| python.cfg | |
| qt.cfg | [Qt](https://doc.qt.io/qt.html) |
| ruby.cfg | |
| sdl.cfg | |
| sfml.cfg | |
| sqlite3.cfg | [SQLite](https://www.sqlite.org/) |
| std.cfg | C/C++ standard library | Loaded by default
| tinyxml2.cfg | [TinyXML-2](https://github.com/leethomason/tinyxml2) |
| vcl.cfg | |
| windows.cfg | [Win32 API](https://learn.microsoft.com/en-us/windows/win32/) |
| wxsqlite3.cfg | |
| wxsvg.cfg | |
| wxwidgets.cfg | [wxWidgets](https://www.wxwidgets.org/) |
| zephyr.cfg | |
| zlib.cfg | [zlib](https://www.zlib.net) |

## Creating a custom .cfg file

You can create and use your own .cfg files for your projects. Use `--check-library` to get hints about what you should configure.

Expand Down

0 comments on commit 0c8ee78

Please sign in to comment.