bpw1621
bpw1621

Reputation: 3062

Any issues with mixing libraries with and without std=c++0x

I am writing a library that must depend libraries that are not presently compiling with support for the new standard. I would like to compile a library which must depend on those libraries with std=c++0x. Are there any problems with doing this?

Upvotes: 12

Views: 2972

Answers (2)

James Kanze
James Kanze

Reputation: 153957

The simple answer is no, unless the vendor explicitly guarantees it (and even then). Practically speaking, all code linked together must use the same standard library, and be compiled with the same version of the compiler, using the same options. There are ways around this, at least for dynamically linked libraries, but they only work if the interface between the libraries is pure C, and you take special steps when linking (special options with dlopen---neither library uses std::string in VC++ pre-version 10, etc.). Otherwise, you're looking for trouble.

Upvotes: 3

Anthony Williams
Anthony Williams

Reputation: 68621

If you mix libraries compiled with different compiler options then you must ensure that the ABI for the data types in the interface is the same. Some data types (such as std::string) have different interfaces and requirements between C++03 and C++0x, so interfaces that use them must be careful.

If your interfaces only use built-in types and your own classes, and these do not themselves use any standard library classes then all should be OK. Otherwise you will need to check the specific subset you are using.

Upvotes: 11

Related Questions