File: unknownMacro.md

package info (click to toggle)
cppcheck 2.20.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 26,924 kB
  • sloc: cpp: 274,396; python: 22,429; ansic: 8,103; sh: 1,094; makefile: 1,041; xml: 987; cs: 291
file content (68 lines) | stat: -rw-r--r-- 2,625 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68

# unknownMacro

**Message**: There is an unknown macro here somewhere. Configuration is required. If AAA is a macro then please configure it. [unknownMacro]
<br/>
**Category**: Configuration<br/>
**Severity**: Error<br/>
**Language**: C and C++

## Description

Cppcheck has found code that is confusing and does not know how to analyze it. This is a critical
error, the analysis of the whole translation unit is aborted. Such error in a header file can mean
that analysis of many source files are aborted.

Your code is probably OK but you need to configure Cppcheck to make Cppcheck understand the code
better.

## How to fix

Review the configuration.

If Cppcheck warns about a macro that is defined in a 3rd party library, and there is a cfg file for
that, then a `--library=` option may be a proper solution.

If Cppcheck warns about a macro that is defined in a header that should be included, make sure that
this header is included properly. Cppcheck must have the include path.

If Cppcheck warns about a compiler keyword add a `-D` that defines this keyword somehow. I.e. if
cppcheck should just ignore the keyword then an `-DKEYWORD=` option is suggested.

## Example

### Example code 1
```
    fprintf(stderr, "Generating up to " F_U64 " sequences and up to " F_U64 " bases.\n", nSeqs, nBases);
```

Warning:

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]

Fix:

Somehow `F_U64` must be specified for Cppcheck to be able to analyse this properly. Either:
 * Add `-DF_U64="x"` to explicitly tell Cppcheck what it should replace F_U64 with. Or;
 * Add `-I..` so that headers are included properly.
 * If the symbol is defined in a 3rd party library adding a corresponding `--library=` might solve such issue.

### Example code 2
```
BOTAN_FUNC_ISA("crypto")
void AES_128::hw_aes_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
```

Warning:

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]

Fix:

Somehow `BOTAN_FUNC_ISA` must be specified for Cppcheck to be able to analyse this properly. Either:
 * Add `-DBOTAN_FUNC_ISA(X)=` to explicitly tell Cppcheck that BOTAN_FUNC_ISA("crypto") should be ignored. Or;
 * Add `-I..` so that headers are included properly.
 * If the symbol is defined in a 3rd party library adding a corresponding `--library=` might solve such issue.