Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++11 compatibility with existing libraries/frameworks

I am wondering something for which I have not found a convincing answer yet.

Situation:

  • A system with some libraries (e.g. gtkmm) compiled without c++11 enabled.
  • An application compiled with C++11 enabled.
  • Both are compiled and linked with the same GCC version/environment.
  • The application has some function calls to the library which use std::string and std::vector.

both std::string and std::vector support move semantics which most likely mean they are not binary compatible with wth non C++11 variants. However both the application and library are build with the same compiler and standard libraries, so it would not be so strange if the lib would recognize this and support it.

Is the above situation safe, or would it be really required to compile everything with the C++11 flag, even if the same build environment is used ?

like image 768
Waldorf Avatar asked Jan 28 '15 19:01

Waldorf


1 Answers

This page is dedicated to g++ abi breaks with c++11 up to version 4.7. The first sentence there is:

The C++98 language is ABI-compatible with the C++11 language, but several places in the library break compatibility. This makes it dangerous to link C++98 objects with C++11 objects.

Though there are examples, where enabling c++11 won't brake ABI compatibility: one example is Qt where you can freely mix c++11 enabled builds with c++03 builds.

like image 198
UldisK Avatar answered Sep 18 '22 18:09

UldisK