简体   繁体   English

msvc预编译头警告抑制

[英]msvc precompiled header warning suppress

In my C++ project, I use precompiled headers as a compile time optimization. 在我的C ++项目中,我使用预编译头作为编译时优化。 However, when I enable /Wall option in the compiler settings, I am not able to suppress any of warnings in the precompiled header file. 但是,当我在编译器设置中启用/ Wall选项时,我无法抑制预编译头文件中的任何警告。

Header File: 头文件:

#ifndef _PRECOMPILED_H
#define _PRECOMPILED_H

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

Source File: 源文件:

#include "precompiled.h"

I end up with tons of warnings in vector. 我最终在向量中发出了大量警告。

When I do the same, but in a regular file, everything works as expected. 当我这样做,但在常规文件中,一切都按预期工作。 Any solutions for this problem? 解决这个问题的方法有哪些

I am using Visual Studio 2013 community edition update 4. 我正在使用Visual Studio 2013社区版更新4。

Don't use /Wall with Visual C++. 不要在Visual C ++中使用/Wall It doesn't mean the same as -Wall with g++. 它与-Wall与g ++的含义不同。 Use /W4 (rough equivalence with g++ -Wall ). 使用/W4 (粗略等效于g ++ -Wall )。

I did not get a 4514 warning from including vector. 我没有得到包含矢量的4514警告。 You have only disabled 4514, and only in the vector header. 您只禁用了4514,并且仅在矢量标题中。 I think this is happening in other code that happens to use vector, and the warning message (which you did not post) refers to the vector header since that's where the function being removed by the optimizer was declared. 我认为这恰好发生在使用vector的其他代码中,并且警告消息(您没有发布)引用了向量头,因为这是优化器删除的函数被声明的地方。

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

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