5

From the early days of the transition between C++98 and C++11, I remember that there was some ABI-related trouble when linking together C++98 libraries and C++11 libraries. (See for example Mixing different C++ standards with GCC and the answers to that question.)

I have a special situation where part of my code needs to be compiled with a tool that only supports C++11, and another part uses C++14 features and can be compiled with a standard g++ that supports them. I can put each part of the code into its own library and link them. But I'm wondering: In general, are there any differences between C++11 and C++14 that would lead to (eg. ABI-related) problems here?

anderas
  • 5,744
  • 30
  • 49

1 Answers1

5

The mixup for gcc was a stdc++ decision (not even gcc). They are indeed incompatible when you set the macro in a different state, but you can mix C++98 with C++11 with libstdc++ if you set it consistently. For instance, on RedHat, the default gcc compiler is old and doesn't support C++11, so the devtools with newer compiler have the macro set to old ABI by default so that they are always compatible.

So if you are consistent with your stdc++ library, no problem. No problem on libc++, VS...

Matthieu Brucher
  • 21,634
  • 7
  • 38
  • 62
  • 1
    Sorry if I wasn't clear about that in my question. But the C++98 situation was only an analogy and the reason for my caution - I was talking about mixing c++11 and c++14, not c++98 and c++11... – anderas Mar 22 '19 at 10:25
  • And I answered, the issue is not with different C++ versions, it's because libstdc++ maintainers decided to break their API *once*. You can safely mix different C++ standards as long as you have a consistent libstdc++ (the others were always fine AFAIK). – Matthieu Brucher Mar 22 '19 at 10:26
  • Ah, I somehow misread that part. BTW, searching for the whole stdc++ library situation lead me to notice that my question is actually a duplicate that I haven't found before. See my close vote... – anderas Mar 22 '19 at 10:50