C ++哈希弃用警告 [英] C++ Hash Deprecation Warning
问题描述
我一般对C ++和编程都不熟悉,目前正在研究Bjarne Stroustrup的《编程:使用C ++的原理和实践》。我一直在收到以下错误消息
I am very new to C++ and programming in general and am currently working through Bjarne Stroustrup's Programming: Principles and Practices using C++. I'm consistently receiving the error below
严重性代码说明项目文件行错误C2338已弃用
,并将被删除。请用 。您可以
定义_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS来确认您已收到此警告
。
Severity Code Description Project File Line Error C2338 is deprecated and will be REMOVED. Please use . You can define _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS to acknowledge that you have received this warning.
我知道头文件std_lib_facilities.h使用某种不推荐使用的功能,但是有办法绕过此功能吗?似乎要我定义 _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS,但是我不确定该怎么做。
I understand that the header file std_lib_facilities.h using some sort of deprecated function, but is there a way to bypass this? It looks like it wants me to define "_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS" but I'm unsure of how to do that. Any help would be appreciated!!
推荐答案
警告不是关于某些功能的问题,而是整个 stdext
。而且它不仅是手工波浪形的,最终会被弃用,最终会被弃用:2015年不提供。
The warning isn't about "some function" - it's about the whole of stdext
. And it's not just hand-wavy, to be discontinued eventually, deprecated: it doesn't ship with 2015.
00年代初期的工作即将修订C ++标准;包括Microsoft在内的不同编译器供应商将建议和原型一起提交给委员会。因此,可以对其进行测试和评估,Microsoft将其扩展建议的实现放入 stdext
。
During the early 00's work was afoot to revise the C++ standard; different compiler vendors, Microsoft included, put proposals before the committee along with prototypes. So they could be tested and evaluated, Microsoft placed implementations of their proposed extensions in stdext
.
最终,委员会选择了他们将要纳入该修订版的内容,并发布了技术报告( TR1)。预期在2009年底之前完成,这被称为 C ++ 0x,编译器供应商开始在 tr1
命名空间中实现这些功能。最终在2011年,该标准得以最终确定,我们将C ++ 11及其所有内容全部归还到它们所属的 std
中。
Eventually the committee chose what they were going to incorporate in that revision and released a Technical Report ("TR1"). Anticipating completion before the end of 2009, this was referred to as "C++0x", and compiler vendors began implementing these features in the tr1
namespace. Finally in 2011 the standard was finalized and we got "C++11" with all its bit and pieces back in std
where they belong.
根据Microsoft的建议,容器将为 std :: hash_map
,但是C ++委员会选择使用术语 unordered_map
。 std :: map
是一个有序的容器, stdext :: hash_map
尽管有名字,却不是。
According to Microsoft's proposal, the container would be std::hash_map
, but the C++ committee chose to use the term unordered_map
. std::map
is an ordered container, stdext::hash_map
, despite the name, is not.
Microsoft的编译器在完成对C ++ 11的完整支持方面一直是最慢的,而标准委员会此后已经完成了第二个版本(C ++ 14),并正在研究第三个版本。 (C ++ 17)。微软即将在VS2015中完成C ++ 11和大部分C ++ 14,但有一些明显的例外显然是VS编译器的主要问题(特别是constexpr和模板变量)。
Microsoft's compiler has been the slowest at getting full C++11 support finished, and the standards committee has since finished a second variation (C++14) and is working on a third (C++17). Microsoft is just-about finishing C++11 in VS2015 and a big chunk of C++14, with a few significant exceptions that are apparently going to be a major problem for the VS compiler (esp constexpr and template variables).
-
Visual Studio 2015不提供
stdext
-它是消失。这不是很好,它最终可能会消失的情况之一。
Visual Studio 2015 does not provide
stdext
- it's gone. This is not one of those "well, it may eventually go away" cases.
stdext
是特定于Microsoft编译器系列的,因此使用 stdext ::
编写代码是不可移植的: http://ideone.com/x8GsKY
stdext
is specific to the Microsoft family of compilers, so writing code using stdext::
anything is not portable: http://ideone.com/x8GsKY
您想要的功能是 std :: unordered_map ,则应使用该功能。
The standardized version of the feature you're wanting is std::unordered_map, you should use that. It's essentially the same thing.
stdext :: hash_map
中有未解决的错误。
如果您确实需要使用 stdext :: hash_map
,请静默通过添加
If you really have to use stdext::hash_map
, silence the warning by adding
#define _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS
$ b警告
$ b
位于 stdafx.h
的顶部,我认为您的项目已经存在,或者位于#之前的头文件中#包括< stdext /...& gt;
,或在解决方案资源管理器中:
at the top of the stdafx.h
I assume your project has, or in your header files before you #include <stdext/...>
, or in the solution explorer:
- 右键单击您的解决方案资源管理器中的项目条目,
- 选择属性,
- 选择配置:
所有配置
, - 展开
C / C ++
树条目, - 选择
预处理程序
, - 预处理程序定义可能会说
<不同的选项>
- 在预处理程序定义条目的开头添加
_SILE NCE_STDEXT_HASH_DEPRECATION_WARNINGS = 1;
,因此它读取_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS = 1;<不同的选项>
。
(或最初出现在;
之后的任何内容)
- Right click on your project's entry in solution explorer,
- Select Properties,
- Select Configuration:
All Configurations
, - Expand the
C/C++
tree entry, - Select
Preprocessor
, - The "Preprocessor Definitions" will probably say
<different options>
- At the beginning of the "Preprocessor Definitions" entry add
_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS=1;
so it reads_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS=1;<different options>
. (or whatever was there originally should follow the;
)
这篇关于C ++哈希弃用警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!