gpt4 book ai didi

c++ - g++ 版本 4.0.0.8 和 4.3.2 之间有什么区别?

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:12:00 24 4
gpt4 key购买 nike

g++ 4.0.0.8 和 g++ 4.3.2 有什么区别?这两个是我在各种编程比赛中看到的最常见的 C++ 编译器。

我尝试用谷歌搜索它,但一无所获。

最佳答案

考虑到您对两者之间的 C++ 变化感兴趣,这确实不是一个“庞大的列表”。

4.0.0.8 只是 4.0 的补丁修订版,其发行说明在这里:http://gcc.gnu.org/gcc-4.0/changes.html

4.3.2 是 4.3 的补丁修订版,其发行说明在这里:http://gcc.gnu.org/gcc-4.3/changes.html

如果您查看它们之间的差异,我认为以下列表涵盖了您真正关心的 GCC 4.0 和 4.3 之间最重要的差异。

GCC 4.3.2 具有(包括来自 GCC 4.1GCC 4.2 的更改):

Experimental support for the ISO C++0x standard (这是一个链接)

更多 TR1 库支持

  • <regex> (海湾合作委员会 4.3),<random> (gcc 4.2), 和 <complex> (海合会 4.2)

C++ 可见性处理已经过彻底修改。 (海湾合作委员会 4.2)

Restricted visiblity is propagated from classes to members, from functions to local statics, and from templates and template arguments to instantiations, unless the latter has explicitly declared visibility.

The visibility attribute for a class must come between the class-key and the name, not after the closing brace.

Attributes are now allowed for enums and elaborated-type-specifiers that only declare a type.

Members of the anonymous namespace are now local to a particular translation unit, along with any other declarations which use them, though they are still treated as having external linkage for language semantics.

GCC 4.2 中删除了未记录的模板扩展(在 4.1 中已弃用)

The (undocumented) extension which permitted templates with default arguments to be bound to template template parameters with fewer parameters has been removed. For example:

template <template <typename> class C>
void f(C<double>) {}

template <typename T, typename U = int>
struct S {};

template void f(S<double>);

is no longer accepted by G++. The reason this code is not accepted is that S is a template with two parameters; therefore, it cannot be bound to C which has only one parameter.


此外,检查 porting to GCC 4.3 guide ,一些重要的东西在哪里,比如:

已删除向后兼容/弃用的 header 。

这主要意味着一堆预标准 header 已被删除,例如 <iostream.h> (使用标准 <iostream> ),<hash_map.h> (使用 <tr1/unordered_map> )<hashtable.h> (根据需要使用 <tr1/unordered_map><tr1/unordered_set>)等。同样,没什么大不了的。

更严格的标准执行

例如main上的签名的双参数形式必须正确。

没有重复的函数参数名

void func(int x, int x); // now an error

还有各种错误修复,以及我认为不会真正影响您编写竞争代码的方式的更改(例如删除/添加新的编译器标志),以及删除像 <? 这样的东西和 >?运算符(用过吗?)。

总而言之,如果您必须为这两种编译器编写代码,我认为两者之间的差异不会让您感到很伤心。

关于c++ - g++ 版本 4.0.0.8 和 4.3.2 之间有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4563340/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com