man/checkers/premium-misra-config.md
Message: Unknown constant x, please review cppcheck options
Category: Configuration
Severity: Information
Language: C and C++
The premium-misra-config message indicates that MISRA checking cannot be performed properly due to missing type information or incomplete code analysis. This typically occurs when the Cppcheck configuration is insufficient for proper code understanding.
These warnings from Cppcheck do not indicate a bug in your code. These warnings indicate that the Cppcheck configuration is not working properly for MISRA analysis.
When MISRA checking requires complete type information to analyze code compliance, missing includes, defines, or other configuration issues can prevent the checker from understanding the code structure needed for accurate MISRA rule evaluation.
The warning is typically reported when MISRA checking encounters code that cannot be properly analyzed due to configuration issues:
// Missing type information may prevent MISRA analysis
typedef some_unknown_type my_type_t; // If some_unknown_type is not defined
my_type_t variable; // MISRA rules cannot be properly checked
Identify which identifier name the warning is about. The warning message will complain about a specific name.
Determine where Cppcheck should find the declaration/definition of that identifier name.
Check if the necessary header(s) are included. You can add --enable=missingInclude to get warnings about missing includes.
cppcheck --enable=missingInclude file.c
Ensure all include directories are specified:
cppcheck -I/path/to/includes file.c
If the code depends on preprocessor macros that are not defined:
cppcheck -DMISSING_MACRO=value file.c