Skip to content

Commit 387d7d8

Browse files
authored
documentation: Add documentation about premium-misra-config warnings [ci skip] (danmar#7914)
1 parent 233c016 commit 387d7d8

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# premium-misra-config
2+
3+
**Message**: Unknown constant x, please review cppcheck options<br/>
4+
**Category**: Configuration<br/>
5+
**Severity**: Information<br/>
6+
**Language**: C and C++
7+
8+
## Description
9+
10+
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.
11+
12+
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.
13+
14+
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.
15+
16+
## How to fix
17+
18+
The warning is typically reported when MISRA checking encounters code that cannot be properly analyzed due to configuration issues:
19+
20+
```cpp
21+
// Missing type information may prevent MISRA analysis
22+
typedef some_unknown_type my_type_t; // If some_unknown_type is not defined
23+
my_type_t variable; // MISRA rules cannot be properly checked
24+
```
25+
26+
Identify which identifier name the warning is about. The warning message will complain about a specific name.
27+
28+
Determine where Cppcheck should find the declaration/definition of that identifier name.
29+
30+
### Missing includes
31+
32+
Check if the necessary header(s) are included. You can add `--enable=missingInclude` to get warnings about missing includes.
33+
```bash
34+
cppcheck --enable=missingInclude file.c
35+
```
36+
37+
Ensure all include directories are specified:
38+
39+
```bash
40+
cppcheck -I/path/to/includes file.c
41+
```
42+
43+
### Preprocessor defines
44+
45+
If the code depends on preprocessor macros that are not defined:
46+
47+
```bash
48+
cppcheck -DMISSING_MACRO=value file.c
49+
```
50+

0 commit comments

Comments
 (0)