stdio.h不是C ++中的标准? [英] stdio.h not standard in C++?
问题描述
我知道大多数编译器允许两者:
#include< stdio.h>
//和
#include< cstdio>
但有人认为< stdio.h>
stdio.h
是标准,但已弃用。
[n3290: C.3.1 / 1]:
为了与标准C库兼容,
C ++标准库提供了18 C头(D.5),但它们的使用是$ b
[n3290:D.5 / 3]:
em> 标题< cstdlib>
确保
在命名空间中提供其声明和定义std
。它
也可以在全局命名空间中提供这些名称。 标题
< stdlib.h>
在全局命名空间中提供了相同的声明和定义
,与C标准。也可以
在命名空间std
中提供这些名称。 -end example ]
I know most compilers allow both:
#include <stdio.h>
//and
#include <cstdio>
But someone argued that <stdio.h> is not actually C++ standard.
is that true?
stdio.h
is standard, but deprecated. Always prefer cstdio
in C++.
[n3290: C.3.1/1]:
For compatibility with the Standard C library, the C++ standard library provides the 18 C headers (D.5), but their use is deprecated in C++.
[n3290: D.5/3]:
[ Example: The header<cstdlib>
assuredly provides its declarations and definitions within the namespacestd
. It may also provide these names within the global namespace. The header<stdlib.h>
assuredly provides the same declarations and definitions within the global namespace, much as in the C Standard. It may also provide these names within the namespacestd
. —end example ]
这篇关于stdio.h不是C ++中的标准?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!