[英]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
.这意味着您需要包含cmath
、 cassert
和ctime
。
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.