cstdint 和 tr1/cstdint 之间的区别

发布于 2024-09-07 13:54:22 字数 506 浏览 5 评论 0原文

之间有什么区别? (除了一个将东西放在命名空间 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

星星的軌跡 2024-09-14 13:54:22

至少据我所知,没有意图在 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 #includeing <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.

中性美 2024-09-14 13:54:22

我想你已经明白了。在我的系统上,它们非常相似,但具有不同的宏观逻辑。例如, /usr/include/c++/4.4/tr1/cstdint 有:

#  define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 {
#  define _GLIBCXX_END_NAMESPACE_TR1 }
#  define _GLIBCXX_TR1 tr1::

但是 /usr/include/c++/4.4/cstdint 有:

#  define _GLIBCXX_BEGIN_NAMESPACE_TR1
#  define _GLIBCXX_END_NAMESPACE_TR1
#  define _GLIBCXX_TR1

所以如果它被包含为 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:

#  define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 {
#  define _GLIBCXX_END_NAMESPACE_TR1 }
#  define _GLIBCXX_TR1 tr1::

but /usr/include/c++/4.4/cstdint has:

#  define _GLIBCXX_BEGIN_NAMESPACE_TR1
#  define _GLIBCXX_END_NAMESPACE_TR1
#  define _GLIBCXX_TR1

So if it's being included as <cstdint> the TR1 namespace is simply defined into oblivion.

为人所爱 2024-09-14 13:54:22

顾名思义,在 TR1,而 是在 c++0x

根据 gcc 手册,需要 -std=c++0x 来启用可能包含在 C++0x 中的实验性功能。但是, 是在 中定义的TR1,而不是 c++0x,所以 不需要 -std=c++0x

以下是-std=c++0x的gcc手册供您参考。

即将推出的 ISO C++0x 标准的工作草案。这
选项启用了可能的实验性功能
包含在 C++0x 中。工作草案不断变化,
并且此标志启用的任何功能都可能被删除
如果它不是 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.

The working draft of the upcoming ISO C++0x standard. This
option enables experimental features that are likely to be
included in C++0x. The working draft is constantly changing,
and any feature that is enabled by this flag may be removed
from future versions of GCC if it is not part of the C++0x
standard.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文