Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Binary compatibility of STL containers

Let's say I write a DLL in C++ and would like to export a method which takes a std::vector parameter. Can I hope for any binary compatibility between different STL versions?

like image 228
quant_dev Avatar asked Apr 20 '11 20:04

quant_dev


2 Answers

I'm not aware of any guarantees of compatibility between versions, not even between release and debug on the same compiler.

One solution is to create a wrapper for the vector. Create a class which has all the functions you require from the container, and implement them in terms of operations on the private vector which is the only member of the class. Keep all the class code in the DLL.

like image 122
Mark Ransom Avatar answered Oct 26 '22 08:10

Mark Ransom


Absolutely not! You can't even rely on the same version of the STL being compatible if it was compiled with a different version of the same compiler.

like image 4
Ferruccio Avatar answered Oct 26 '22 09:10

Ferruccio