Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/135.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 仅针对成员变量的-Wshadow警告_C++_Visual Studio_Gcc_Clang - Fatal编程技术网

C++ 仅针对成员变量的-Wshadow警告

C++ 仅针对成员变量的-Wshadow警告,c++,visual-studio,gcc,clang,C++,Visual Studio,Gcc,Clang,我只想捕捉成员变量的阴影,例如: class MyClass { std::string _s; void foo() { std::string _s = "oops, shadows the member variable"; } }; 我找到的最好的是-Wshadow,但它太宽了,也警告了局部阴影。我希望通过-Werror=向Qt的CI添加这样的警告,因为我们在成员跟踪方面遇到了一些错误。添加-Werror=shadow根本无法飞行,因为有数百条警

我只想捕捉成员变量的阴影,例如:

class MyClass {
    std::string _s;
    void foo() {
        std::string _s = "oops, shadows the member variable";
    }
};
我找到的最好的是-Wshadow,但它太宽了,也警告了局部阴影。我希望通过-Werror=向Qt的CI添加这样的警告,因为我们在成员跟踪方面遇到了一些错误。添加-Werror=shadow根本无法飞行,因为有数百条警告,看起来都是良性的


MSVC特定的选项也适用于我。

-Wshadow
有各种子模式(请参阅),但没有一个与您想要的完全相同。