Chapter 3. Preprocessor configurations

By default Cppcheck will check all preprocessor configurations (except those that has #error in them). This is the recommended behaviour.

But if you want to manually limit the checking you can do so with -D.

Beware that only the macros, which are given here and the macros defined in source files and known header files are considered. That excludes all the macros defined in some system header files, which are by default not examined by cppcheck.

The usage: if you, for example, want to limit the checking so the only configuration to check should be "DEBUG=1;__cplusplus" then something like this can be used:

cppcheck -DDEBUG=1 -D__cplusplus path

An alternative for -D is to use #error.

#if LIB_VERSION <= 3
#error "lib version must be greater than 3"
#endif

Using #error instead of -D have some advantages: