Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gnu c++0x backwards compatibility status - can I just switch it on and go?

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.

like image 508
AndreasT Avatar asked Mar 26 '11 10:03

AndreasT


2 Answers

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.

like image 58
rubenvb Avatar answered Sep 29 '22 16:09

rubenvb


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.

like image 30
Mat Avatar answered Sep 29 '22 14:09

Mat