C++ 如何在VS2013社区中禁用警告C4927

C++ 如何在VS2013社区中禁用警告C4927,c++,c++11,warnings,C++,C++11,Warnings,我在我的项目中收到以下警告: warning C4927: illegal conversion; more than one user-defined conversion has been implicitly applied while calling the constructor 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>::basic_string(con

我在我的项目中收到以下警告:

warning C4927: illegal conversion; more than one user-defined conversion has been implicitly applied while calling the constructor 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>::basic_string(const _Elem *)'
      with
      [
          _Elem=char
      ]
      C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xstring(778) : see declaration of 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>::basic_string'
警告C4927:非法转换;调用构造函数“std::basic\u string::basic\u string(const\u Elem*)”时,隐式应用了多个用户定义的转换
具有
[
_元素=字符
]
C:\ProgramFiles(x86)\Microsoft Visual Studio 12.0\VC\include\xstring(778):请参阅“std::basic_string::basic_string”的声明

我明白为什么会这样,我只是无法抑制它。我已尝试将其添加到“项目设置”中的“禁用特定警告”列表中,并将警告级别设置为“关闭所有警告”(/W0),但警告仍然存在。有人对如何隐藏消息有什么建议吗?

您可以使用
#pragma warning
()直接在代码中控制Visual Studio警告。如果要使单行警告静音,可以将以下内容放在该行之前:

#pragma warning (suppress: 4927)
line-that-causes-warning-4927

您还可以使用“禁用”而不是“抑制”,从
#pragma
之后的任何点禁用它。但是,正如评论所建议的那样,最好实际修复警告,因为它可能会导致程序出现问题。

您能否在生成此警告的代码中发布该行?如果您的问题有效,我怀疑您的意图。一级警告是永远不应该被禁用的严重警告。我不厌其烦地表示,我只对抑制警告感兴趣。所讨论的代码是一个奇怪的类,它拥有在wchar_t*、wstring、char*和string之间自动转换所需的所有可能的类型运算符和构造函数。我注意到,在它短暂存在期间,出现了一个警告,它似乎对所有IDE设置都不敏感。