我们需要用c ++ 11重新编译库吗? [英] do we need to recompile libraries with c++11?

查看:166
本文介绍了我们需要用c ++ 11重新编译库吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个非常无知的问题,但是:

This is a very uninformed question, but:

我想开始使用C ++ 11.我可以继续使用我的旧gcc 4.2.1编译器编译的大量库吗,还是需要使用新的编译器重新编译它们?我认为(或希望)答案是否定的,但我只是一个涉水者.

I would like to start using C++11. Can I continue to use my large collection of libraries which were compiled with my old gcc 4.2.1 compiler or do I need to recompile them all with a new compiler? I would think (or hope) the answer is no, but I am only a dabbler.

为使我至少可以消除部分无知,您能解释为什么在两种情况下都是这样吗?

So that I may have at least part of my ignorance removed, can you explain why in either case?

谢谢

推荐答案

是的,你应该.

较弱的原因不是二进制兼容性,问题在于期望.启用C ++ 11的编译器将期望许多功能可用(在其中移动构造函数)并在适当的时候使用它们.但这仅仅是冰山的一角,还有其他一些不兼容性(auto0及其与指针的交互,...).

The weaker reason is not binary compatibility, the problem is about expectations. A C++11 enabled compiler will expect a number of features to be available (move constructors among them) and use them when appropriate. And that's only scratching the tip of the iceberg, there are several other incompatibilities (auto, 0 and its interaction with pointers, ...).

这意味着,根据C ++ 11标准,标头中的任何内联方法可能突然被不同地解释.

It means that any inline method in a header may suddenly be interpreted differently, in light of the C++11 Standard.

更有力的理由是每个版本的编译器都带有其自己的标准库实现.您真的不希望开始混用各种版本,尤其是当它们经历了如此重大的更改时(尤其是右值引用...).

The stronger reason is that each version of the compiler comes with its own Standard Library implementation. You don't really want start mixing various versions around and especially not when they have undergone such major changes (once again, rvalue references...).

相信我,现在重新编译比起simple的认为每个出现的错误可能是由于旧库与新库之间不兼容而导致的更容易.

Believe me, it's simpler to recompile now rather than having that nagging thought that each bug that appear may be due to an incompatibility between old and new libraries...

这篇关于我们需要用c ++ 11重新编译库吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆