开发者

What are the differences between g++ version 4.0.0.8 and 4.3.2?

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 goo开发者_如何学编程gle 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.


You are wondering about the difference between two different version of g++? It's two common version of GNU C++ compilers. Different Linux releases may have different version of g++ shipped with it. Like my current CentOS 5.5 has g++ 4.1.2 with it.

For you feature details, check the link in you comments.


Since the 4.3.2 is newer then 4.0.0.8, it is more standard compliant. For details, you have to check documentation and release changes

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜