mardi 25 octobre 2016

Can an app compiled against GNU++98 / libstdc++ link to a dylib built against C++11 / libc++?

I have a C++ app that is built with Xcode 7.2.1, compiled with the GNU++98 dialect and linked against libstdc++. I need to make calls into a dylib that is compiled with C++11 and linked against libc++.

Using the default attribute visibility in the dylib's class members:

extern __attribute__((visibility("default"))) void foo(std::string const&, int);

...shows there isn't ABI compatibility (at least for strings) -- any dylib function that has a param of std::string cannot be linked to the app.

Is an appropriate solution to create a overloaded C++ member functions that only pass char* params that get constructed on the dylib side into std::string, or are there other gotchas requiring the creation of a pure C API for the dylib?

Aucun commentaire:

Enregistrer un commentaire