cstdint 和 tr1/cstdint 之间的区别
和
之间有什么区别? (除了一个将东西放在命名空间 std::
中,另一个放在 std::tr1::
中)
因为这些东西还不是标准的,我猜它是编译器特定的所以我说的是海湾合作委员会。要使用非 tr1 进行编译,我必须使用 -std=c++0x
进行编译,但使用 tr1 时没有这样的限制。
答案可能是没有,但你不能到处向 std::
添加东西,除非有标准。因此,在 c++0x 标准化之前,必须使用
发出错误,但在添加到 tr1::
命名空间时无需担心,这使得声称其中的事物是标准的?或者还有更多的事情吗?
谢谢。
ps - 如果您像我一样将“std”视为标准,我为这个问题中过度使用该词表示歉意。
What is the difference between <cstdint>
and <tr1/cstdint>
? (apart from that one puts things in namespace std::
and the other in std::tr1::
)
Since this stuff isn't standard yet I guess it's compiler specific so I'm talking about gcc. To compile with the non-tr1 one I must compile with -std=c++0x
, but there is no such restriction when using tr1.
Is the answer perhaps that there is none but you can't go around adding things to std::
unless there, well, standard. So until c++0x is standardised an error must be issued using <cstdint>
but you dont need to worry when adding to the tr1::
namespace, which makes no claim to things in it being standard? Or is there more to this?
Thanks.
p.s - If you read "std" as standard, as I do, I do apologise for the overuse of the word in this Q.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
至少据我所知,没有意图在 TR1 和 C++0x 之间更改
。不过,#include
并不要求
会导致错误 - 正式来说,这只不过是未定义的行为。允许实现指定确切的行为,在本例中确实如此。At least as far as I know, there was no intent to change
<cstdint>
between TR1 and C++0x. There's no requirement for#include
ing<cstdint>
to result in an error though -- officially, it's nothing more or less than undefined behavior. An implementation is allowed to specify exact behavior, and in this case it does.我想你已经明白了。在我的系统上,它们非常相似,但具有不同的宏观逻辑。例如,
/usr/include/c++/4.4/tr1/cstdint
有:但是 /
usr/include/c++/4.4/cstdint
有:所以如果它被包含为
TR1 命名空间被简单地定义为遗忘。I think you've got it. On my system, they're very similar, but with different macro logic. For instance,
/usr/include/c++/4.4/tr1/cstdint
has:but /
usr/include/c++/4.4/cstdint
has:So if it's being included as
<cstdint>
the TR1 namespace is simply defined into oblivion.
顾名思义,在 TR1,而
是在 c++0x。根据 gcc 手册,需要
-std=c++0x
来启用可能包含在 C++0x 中的实验性功能。但是,
是在 中定义的TR1,而不是 c++0x,所以不需要 -std=c++0x
。以下是
-std=c++0x
的gcc手册供您参考。<tr1/cstdint>
is defined, as name suggests, in TR1, while<cstdint>
is defined in c++0x.From gcc manual,
-std=c++0x
is needed to enable experimental features that are likely to be included in C++0x. However,<tr1/cstdint>
is defined in TR1, not c++0x, so-std=c++0x
is no needed.The following is gcc manual for
-std=c++0x
for your reference.