c++ - msvc预编译头警告抑制

标签 c++ visual-c++ compiler-warnings precompiled-headers

在我的 C++ 项目中,我使用预编译头作为编译时优化。但是,当我在编译器设置中启用/Wall 选项时,我无法抑制预编译头文件中的任何警告。

头文件:

#ifndef _PRECOMPILED_H
#define _PRECOMPILED_H

#pragma warning(push, 0)
#pragma warning(disable: 4514)
#include <vector>
#pragma warning(pop)
#endif /* _PRECOMPILED_H */

源文件:

#include "precompiled.h"

我最终在 vector 中收到了大量警告。

当我做同样的事情,但在常规文件中时,一切都会按预期进行。 这个问题有什么解决办法吗?

我正在使用 Visual Studio 2013 社区版更新 4。

最佳答案

请勿将 /Wall 与 Visual C++ 一起使用。它与 g++ 中的 -Wall 含义不同。使用 /W4 (与 g++ -Wall 大致等效)。

关于c++ - msvc预编译头警告抑制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28517343/

相关文章:

c++ - 在 .h 文件中声明静态常量 vector 时出错,在 .cpp 文件中定义时出错

c++ - 使用相机获取方法时无法使用 wxWidgets 加载 tiff 图像

c++ - 迭代指针的 std::vector 时出错

compiler-construction - FSC 编译警告 : Assembly 'SMDiagnostics' was referenced transitively and the assembly could not be resolved automatically

c++ - g++ 中的 "warning: use of old-style cast"

c++ - 将十六进制字符串解析为二进制字符的最佳方法

C++ WinForms 参数通过 System::Threading::ParameterizedThreadStart

C++ 编译器错误 - 'No matching function for call...'

c++ - 是否存在 C4930 Visual C++ 警告未指示错误的真实案例?

Python:PyDev 中的 "Unused variable"警告