0

I have a file that can be summarized as shown below.

namespace MyNamespace {

#if defined(SOME_UNSET_CONDITION)

TEST_CASE("STR1", "[STR2]") {
}

TEST_CASE("STR3", "[STR4]") {
}

#endif

}

When calling Cppcheck v2.8 on the file, the following is the output:

$ cppcheck --std=c++14 -v tmp.cpp
Checking tmp.cpp ...
Defines:
Undefines:
Includes:
Platform:Native
Checking tmp.cpp: SOME_UNSET_CONDITION...
tmp.cpp:8:1: error: syntax error [syntaxError]
TEST_CASE("STR3", "[STR4]") {
^

The SOME_UNSENT_CONDITION directive is not currently enabled in this project, though I'm not sure why cppcheck would be complaining either way. Can anyone give me some insight here?

mitchute
  • 389
  • 1
  • 3
  • 10

1 Answers1

3

Can anyone give me some insight here?

From https://cppcheck.sourceforge.io/manual.pdf :

Automatic configuration of preprocessor defines

Cppcheck automatically test different combinations of preprocessor defines to achieve as high coverage in the analysis as possible.

By that it is meant that cppcheck checks every possible combination of all possible defines in your project.

If you intent to disable checking a specific combination, -USOME_UNSET_CONDITION for cppcheck.

KamilCuk
  • 120,984
  • 8
  • 59
  • 111
  • thanks for your response. So, is this error trying to indicate that it's attempting to check `TEST_CASE`, but that it doesn't know where to find it? `syntaxError` seems like the wrong error to throw if that's true. – mitchute Jun 23 '22 at 15:48
  • `TEST_CASE("STR3", "[STR4]") {` is invalid function declaration, it's a syntax error, I do not understand. `is this error trying to indicate that it's attempting to check TEST_CASE` Yes. `that it doesn't know where to find it?` Yes. – KamilCuk Jun 23 '22 at 15:56