Dzid - 2024-07-27

Example:

#ifdef Variant1
uint32_t value = 0;
#endif
#ifdef Variant2
uint32_t value = 1;
#endif

int main(void){
    if (value > 0U) {
        return 0;
      }
}

Command:
cppcheck --addon=misra --force 5.c
Result:

Checking 5.c ...
Checking 5.c: Variant1...
Checking 5.c: Variant2...
5.c:9:9: error: Because of missing configuration, misra checking is incomplete. There can be false negatives! Variable 'value' is unknown [misra-config]
    if (value > 0U) {
        ^

This is a simple example. In the real code, behind #ifdefs, there are multiple includes depending on the program variant.

--force checks empty configuration which causes [misra-config] (and also [unknownMacro]) errors.

How to make --force not check the empty configuration?

Also, the error display is a bit confusing - it's printed directly under Variant2, but it's not related to it.