3

When I am compiling my code with C++11 support (using the -std=c++11 flag) and use non-header-only Boost libraries, then I need to have Boost compiled with -std=c++11. This is because Boost has some interface differences in header files when C++11 is enabled, and some function signatures are different for the different C++ standards.

My question is whether the same is true with C++14 (using g++ 4.9, with the `-std=c++1y flag), or is it safe to use Boost compiled with C++11 for a program compiled with C++14?

TemplateRex
  • 69,038
  • 19
  • 164
  • 304
petersohn
  • 11,292
  • 13
  • 61
  • 98
  • 1
    Nothing will be safe until the C++14 standard is finalised, which, at the time of writing, is not case. As its scope is broadly limited to fixes to C++11 I'd imagine you would get away with using -std=c++11. – Bathsheba May 22 '14 at 07:35
  • I don't think that C++14 will be 100% retro-compatible with C++11, there is at least 1 case that, at this point in time, it's being handled differently in this 2 standards ( of course C++14 it's not here yet so everything about it is hypothetical ). – user2485710 May 22 '14 at 07:37

1 Answers1

4

This is a very broad question that is difficult to answer definitively, because

  • Boost is a federation of libraries, many of which are over decade old
  • there are quite a lot of backward compatibilities that could in principle happen, some detected by the compiler, and some only by unit tests
  • many Boost libraries are actually C++98 implementations of C++11/14 features (both library and compiler functionality), so that you would not need to use this in a C++11/14 project.
  • Boost itself is very much debating at which pace the library should be updated to C++11/14, whether V2 versions of libraries should be written that fully take advantage of C++11/14, and even whether new C++11/14 libraries should offer backward C++98 compatibility

You might want to closely read your compiler errors (if any) and compare them to the list of breaking changes listed below. Furthermore, I would recommend following the Boost test harness for finding suspect compiler/library combinations that apply to your system.

Some relevant Q&A's here:

  1. What breaking changes are introduced in C++11?
  2. What changes introduced in C++14 can potentially break a program written in C++11?
  3. Relevant boost features vs C++11
  4. How well does boost use c++11?
Community
  • 1
  • 1
TemplateRex
  • 69,038
  • 19
  • 164
  • 304