警告 C4101 未引用的局部变量

Bui*_*ded 2 c++ compiler-warnings

void func(char * param)
{
#ifdef _XYZ_
.....somecode here using param
#endif
.....lots of code here not using param
}
Run Code Online (Sandbox Code Playgroud)

编译出错,我什至不希望在代码中发出警告。

Evg*_*Evg 5

从 C++17 开始,我们具有抑制未使用实体的警告的maybe_unused属性

void func([[maybe_unused]] char * param)
{
#ifdef _XYZ_
.....somecode here using param
#endif
}
Run Code Online (Sandbox Code Playgroud)