g ++ 4.0.0.8和4.3.2之间有什么区别? [英] What are the differences between g++ version 4.0.0.8 and 4.3.2?

查看:118
本文介绍了g ++ 4.0.0.8和4.3.2之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

g ++ 4.0.0.8和g ++ 4.3.2之间有什么区别?这两个是我在各种编程竞争中使用的最常见的C ++编译器。



我尝试google了,但什么也没找到。

解决方案

这真的不是一个巨大的列表,考虑你对C ++之间的变化感兴趣。



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



4.3.2是4.3的修补版本,其发布说明在这里: a href =http://gcc.gnu.org/gcc-4.3/changes.html> http://gcc.gnu.org/gcc-4.3/changes.html



如果你看看他们之间的差异,我认为下面的列表涵盖了GCC 4.0和4.3之间,你真正关心的最重要的区别。



GCC 4.3.2具有(包括 GCC 4.1 GCC 4.2 ):



ISO C ++ 0x标准的实验支持 (这是一个链接)





更多TR1库支持




  • < regex> ; (gcc 4.3),< random> (gcc 4.2)和< complex> (gcc 4.2)



C ++可见性处理已大修。 (GCC 4.2)


限制可见性从类传递到成员,从函数传播到本地静态,



类的可见性属性必须位于类键和名称之间,而不是在结束括号之后。



现在只允许枚举和阐明类型说明符的属性只声明一个类型。



匿名命名空间现在对于特定翻译单元是局部的,以及使用它们的任何其他声明,尽管它们仍被视为具有语言语义的外部链接。


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


已删除了允许使用默认参数绑定到具有较少参数的模板模板参数的模板的(无记录)扩展。例如:




 模板< template< typename>类C> 
void f(C< double>){}

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

template void f(S< double>); G ++不再接受




不接受此代码的原因是S是具有两个参数的模板;因此,它不能绑定到只有一个参数的C。







此外,请检查移植到GCC 4.3指南,其中一些重要的信息如下:


$ b

已删除一组预标准标题,例如< iostream.h> (使用标准< iostream> ),< hash_map.h> (使用< tr1 / unordered_map> < hashtable.h> (使用< tr1 / unordered_map> < tr1 / unordered_set>



更严格的标准执行



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



没有重复的函数参数名称

  void func(int x,int x) ; //现在出现错误






错误修复以及更改我不认为真正影响你如何编写竞争代码(如删除/添加新的编译器标志),并删除的东西,如<?>?运算符(曾经使用过?)。



如果你必须为两个编译器编写代码,那么两者之间的差异将导致你的悲痛。


What's the difference between g++ 4.0.0.8 and g++ 4.3.2? These two are the most common C++ compilers that I have seen used in various programming competitions.

I tried to google it, but found nothing.

解决方案

It's really not such a 'huge list', considering you're interested in the C++ changes between the two.

4.0.0.8 is just a patch revision of 4.0, whose release notes are here: http://gcc.gnu.org/gcc-4.0/changes.html

4.3.2 is a patch revision of 4.3, whose release notes are here: http://gcc.gnu.org/gcc-4.3/changes.html

If you look at the differences between them, I think the following list covers the most important differences between GCC 4.0 and 4.3 that you would really care about.

GCC 4.3.2 has (including changes from GCC 4.1 and GCC 4.2):

Experimental support for the ISO C++0x standard (that's a link)

  • long long is now officially supported in C++ (though it was an extension provided in older GCC anyway)
  • Template extern is supported
  • Right angle brackets like you'd see in std::vector<std::vector<int>> are now supported (note the lack of a space between the two > at the end of the declaration).
  • experimental support for Variadic Template Arguments
  • Static assertions
  • and some others

More TR1 library support

  • <regex> (gcc 4.3), <random> (gcc 4.2), and <complex> (gcc 4.2)

C++ visibility handling has been overhauled. (GCC 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.

An undocumented template extension was removed in GCC 4.2 (was deprecated in 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.


Additionally, check the porting to GCC 4.3 guide, where some important stuff is, like:

Backward compatible/deprecated headers have been removed.

Mostly this means a bunch of pre-standard headers have been removed, like <iostream.h> (use the standard <iostream>), <hash_map.h> (use <tr1/unordered_map>) <hashtable.h> (use <tr1/unordered_map> or <tr1/unordered_set> depending on needs), etc. Again, not a big deal.

Stricter enforcement of standards

For example, the signature on main's two-argument form must be correct.

No duplicate function parameter names

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


And there have been various bug fixes, as well as changes I don't think really affect how you'd write competition code (like removal/addition of new compiler flags), and removal of stuff like the <? and >? operators (ever used those?).

All in all I don't think the differences between the two will cause you much grief if you had to write code for both compilers.

这篇关于g ++ 4.0.0.8和4.3.2之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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