Skip to content

Commit 052538e

Browse files
Fix #14475 (Document unknownMacro) (danmar#8194)
Co-authored-by: chrchr-github <78114321+chrchr-github@users.noreply.github.com>
1 parent bd5ff18 commit 052538e

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

man/checkers/unknownMacro.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
2+
# unknownMacro
3+
4+
**Message**: There is an unknown macro here somewhere. Configuration is required. If AAA is a macro then please configure it. [unknownMacro]
5+
<br/>
6+
**Category**: Configuration<br/>
7+
**Severity**: Error<br/>
8+
**Language**: C and C++
9+
10+
## Description
11+
12+
Cppcheck has found code that is confusing and does not know how to analyze it. This is a critical
13+
error, the analysis of the whole translation unit is aborted. Such error in a header file can mean
14+
that analysis of many source files are aborted.
15+
16+
Your code is probably OK but you need to configure Cppcheck to make Cppcheck understand the code
17+
better.
18+
19+
## How to fix
20+
21+
Review the configuration.
22+
23+
If Cppcheck warns about a macro that is defined in a 3rd party library, and there is a cfg file for
24+
that, then a `--library=` option may be a proper solution.
25+
26+
If Cppcheck warns about a macro that is defined in a header that should be included, make sure that
27+
this header is included properly. Cppcheck must have the include path.
28+
29+
If Cppcheck warns about a compiler keyword add a `-D` that defines this keyword somehow. I.e. if
30+
cppcheck should just ignore the keyword then an `-DKEYWORD=` option is suggested.
31+
32+
## Example
33+
34+
### Example code 1
35+
```
36+
fprintf(stderr, "Generating up to " F_U64 " sequences and up to " F_U64 " bases.\n", nSeqs, nBases);
37+
```
38+
39+
Warning:
40+
41+
canu-2.2/src/seqrequester/src/seqrequester/generate.H:72:41: error: There is an unknown macro here somewhere. Configuration is required. If F_U64 is a macro then please configure it. [unknownMacro]
42+
43+
Fix:
44+
45+
Somehow `F_U64` must be specified for Cppcheck to be able to analyse this properly. Either:
46+
* Add `-DF_U64="x"` to explicitly tell Cppcheck what it should replace F_U64 with. Or;
47+
* Add `-I..` so that headers are included properly.
48+
* If the symbol is defined in a 3rd party library adding a corresponding `--library=` might solve such issue.
49+
50+
### Example code 2
51+
```
52+
BOTAN_FUNC_ISA("crypto")
53+
void AES_128::hw_aes_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
54+
```
55+
56+
Warning:
57+
58+
botan-2.19.5+dfsg/src/lib/block/aes/aes_power8/aes_power8.cpp:103:1: error: There is an unknown macro here somewhere. Configuration is required. If BOTAN_FUNC_ISA is a macro then please configure it. [unknownMacro]
59+
60+
Fix:
61+
62+
Somehow `BOTAN_FUNC_ISA` must be specified for Cppcheck to be able to analyse this properly. Either:
63+
* Add `-DBOTAN_FUNC_ISA(X)=` to explicitly tell Cppcheck that BOTAN_FUNC_ISA("crypto") should be ignored. Or;
64+
* Add `-I..` so that headers are included properly.
65+
* If the symbol is defined in a 3rd party library adding a corresponding `--library=` might solve such issue.
66+
67+
68+

0 commit comments

Comments
 (0)