gnu c++0x 向后兼容性状态 - 我可以打开它然后继续吗?

发布于 2024-10-26 23:40:34 字数 740 浏览 0 评论 0原文

我有一个相当大的 C++ 代码库(不是自己编写的)。 有很多库,有些在语法上不那么重,有些则非常重。 其中大量使用了 Boost,还有一些 Eigen。

我只是喜欢 0x 的一些新功能,快速编译/测试告诉我,它看起来一切都很好。 这个问题这个表明有些东西闻起来很有趣。

我当前的状态是:

  • gcc4.4.3
  • libstc++6-4.4
  • boost-1.40
  • eigen 3.0 - beta3

使用 std=c++0x 标志。

我知道标准委员会一直在为向后兼容性而苦恼并承受着严重的痛苦。 我的问题是,它有效吗?我可以获取所有代码,打开 c++0x 并确定所有内容不仅可以编译,而且可以按预期工作吗?

我不使用高 0x 魔法,只是使用 auto 和一些常用的在 GNU C++0x 状态

I have a pretty big c++ code base (not self written).
Numerous libraries, some not so syntactically heavy, some extremely so.
Among others there's heavy use of Boost, some Eigen.

I just love some of the new features of 0x and a quick compile/test tells me that it seems all good.
This question, and this one suggest that there are some things that smell funny.

My current state is:

  • gcc4.4.3
  • libstc++6-4.4
  • boost-1.40
  • eigen 3.0 - beta3

using the std=c++0x flag.

I know the standards committee has agonized about backwards compatibility and endured serious pain.
My question is, did it work? Can I take all that code, switch on c++0x and be certain, that everything does not only compile but also work as expected?

I don't use high 0x magic, just auto and some of the usual favorites explicitly marked "implemented" on GNU C++0x status.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

烟柳画桥 2024-11-02 23:40:34

我当然会推荐使用 GCC 4.5,因为它修复了更多错误并更可靠地实现了最新的 C++0x。

关于您链接的问题:

  1. 这只是新平台上的类型定义。不要担心这一点,它不会真正破坏任何东西或难以修复。

  2. 这是更复杂的 C++0x 功能之一,但不应该对向后兼容性产生太大影响(除非 boost 试图将自己侵入到将成为编译器/语言功能的功能中) .

检查是否存在问题的唯一真正方法是打开编译器标志,并查看是否弹出任何问题。更好的是,打开全面的警告(至少在 GCC 上,MSVC 在这方面有一些棘手的问题)来检测尽可能多的被破坏的问题。但这并不防水。您可能想要使用不同的编译器(GCC/MSVC/Intel/Clang)来交叉检查兼容性,但在 c++0x 的情况下,您将非常限于用于检查的编译器的公共子集。目前我广泛使用C++0x,并打算解决在实现最终标准时出现的任何问题。

I would certainly recommend using GCC 4.5, as it sports more bug fixes and a more solid implementation of the latest C++0x.

With regard to the questions you linked:

  1. This is just a type definition on a new platform. Don't worry about this, it won't really break anything or be hard to fix.

  2. This is one of the more complicated C++0x features, but shouldn't have that much of an influence on backwards compatibility (except if boost tries to hack itself into a feature that is to become a compiler/language feature).

The only real way to check if there are problems, is to turn on the compiler flag, and see if any problems pop up. Better yet, turn on full-fledged warnings (at least on GCC, MSVC has some nagging problems in this regard) to detect as many subverted problems as possible. This isn't waterproof though. You might want to use different compilers (GCC/MSVC/Intel/Clang) to cross-check compatibility, but in the case of c++0x you'll be very limited to the common subset of the compilers you use to check. Currently I use C++0x extensively, and intend to fix any problems that come into being when the finalized standard is implemented.

是你 2024-11-02 23:40:34

你的问题没有答案,这取决于你的代码。尝试编译,修复编译时问题。编译后,运行测试用例,并修复需要修复的任何问题。

如果您没有测试代码,请从这里开始。

There is no answer to your question, it depends on your code. Try to compile, fix compile-time problems. Once it compiles, run your test cases, and fix whatever needs to be fixed.

If you don't have test code, start there.

淡淡離愁欲言轉身 2024-11-02 23:40:34

如果不了解代码库,就无法回答这个问题。特别是,在 100% 向后兼容性的情况下,您可能会发现通过升级/更改同一标准内的编译器会发现的相同问题:

如果您的代码不是标准的,如果它使用特定于编译器或版本的功能,如果它有任何未定义行为的实例,或者依赖于恰好在您当前平台上工作的未指定行为,那么它可能无法编译(如果您幸运的话)或在运行时表现出不同的行为(如果您不幸运)。

This cannot be answered without knowledge of the code base. In particular, with 100% backwards compatibility you might find the same issues that you can find by upgrading/changing a compiler within the same standard:

If your code is not standard, if it uses features that are specific to the compiler or version, if it has any instance of undefined behavior or depends on unspecified behaviors that just happen to work in your current platform, then if might not compile (if you are lucky) or exhibit different behavior at runtime (if you are not lucky).

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