简体   繁体   English

弃用 Header 警告 (C++)

[英]Deprecated Header warning (C++)

I keep receiving the deprecated header warning:我不断收到已弃用的 header 警告:

#ifdef __DEPRECATED
#warning This file includes at least one deprecated or antiquated header. \
Please consider using one of the 32 headers found in section 17.4.1.2 of the \
C++ standard. Examples include substituting the <X> header for the <X.h> \
header for C++ includes, or <iostream> instead of the deprecated header \
<iostream.h>. To disable this warning use -Wno-deprecated.
#endif

However, I don't see any deprecated header called by my project (including the headers called by my libraries).但是,我没有看到我的项目调用的任何已弃用的 header(包括我的库调用的标头)。 These are the header I am loading (or, at least the ones that I am seeing): iostream math.h assert.h fstream vector time.h .这些是我正在加载的 header(或者,至少是我看到的那些): iostream math.h assert.h fstream vector time.h

In section 17.4.1.2 http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1905.pdf there is only a list of the header one should use. In section 17.4.1.2 http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1905.pdf there is only a list of the header one should use.

1) Is there somewhere a list of the deprecated ones? 1) 某处是否有已弃用的列表?

2) Any idea on how to get out of the preprocessor which one is the exact header he doesn't like? 2) 关于如何摆脱预处理器的任何想法,哪一个是他不喜欢的确切 header?

CHEERS!干杯!

The headers coming from the C world are to be prefixed with c , and not postfixed.来自 C 世界的标题将以c为前缀,而不是后缀。
That means you'll want to include cmath , cassert and ctime .这意味着您需要包含cmathcassertctime

In those cases, only the header name is subject to deprecation, not the contents.在这些情况下,只有 header 名称会被弃用,而不是内容。

Note : you can deduce which headers are subject to this kind of deprecation by matching their names in the document you link to.注意:您可以通过在链接到的文档中匹配它们的名称来推断哪些标题会受到这种弃用。

Obviously, this only works for standard headers.显然,这只适用于标准标题。 For instance, unistd.h will always be unistd.h .例如, unistd.h将始终是unistd.h

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

相关问题 警告:在C ++模式下将&#39;c-header&#39;输入视为&#39;c ++ - header&#39;时,不推荐使用此行为 - Warning: treating 'c-header' input as 'c++-header' when in C++ mode, this behavior is deprecated 如何为COM界面中的方法生成不建议使用的警告(C ++) - How to generate deprecated warning for a method in a COM interface (c++) C ++:覆盖不推荐使用的虚方法时的弃用警告 - C++: Deprecation warning when overriding a deprecated virtual method 在C ++模式下,将“ c-header”输入视为“ c ++-header”,不建议使用此行为 - Treating 'c-header' input as 'c++-header' when in C++ mode, this behavior is deprecated C++ 标记为已弃用 - C++ mark as deprecated C++ 绑定(已弃用) - C++ bindings (deprecated) C ++中不推荐使用的强制转换 - Deprecated casts in C++ 使用 function IsWin2000() 会产生 C++ 警告:C4996 - 已弃用 Function - Use of the function IsWin2000() produces a C++ warning: C4996 - Deprecated Function 不推荐使用Clang-CL警告strnicmp,使用符合ISO C和C ++标准的名称_strnicmp - Clang-CL warning strnicmp is deprecated, use ISO C and C++ conformant name _strnicmp 如何处理Boost选项头文件中与C ++相关的警告? - how to deal with a c++ related warning in boost option header file?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM