简体   繁体   English

cppcheck 使用 #ifdef 引发 syntaxError

[英]cppcheck throws syntaxError with #ifdef

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 v2.8 时,输出如下:

$ 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. SOME_UNSENT_CONDITION指令当前未在此项目中启用,但我不确定为什么cppcheck会抱怨任何一种方式。 Can anyone give me some insight here?谁能在这里给我一些见解?

Can anyone give me some insight here?谁能在这里给我一些见解?

From https://cppcheck.sourceforge.io/manual.pdf :来自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. Cppcheck 自动测试预处理器定义的不同组合,以在分析中实现尽可能高的覆盖率。

By that it is meant that cppcheck checks every possible combination of all possible defines in your project.这意味着 cppcheck 检查项目中所有可能定义的每个可能组合

If you intent to disable checking a specific combination, -USOME_UNSET_CONDITION for cppcheck.如果您打算禁用检查特定组合,请使用-USOME_UNSET_CONDITION进行 cppcheck。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM