Binary compatibility of STL containers

徘徊边缘 提交于 2019-12-05 08:31:56

If you mean between the versions included with updated versions of the same compiler, yes, it can (and will) work in some cases, but you have to be careful. There are also a few special cases, such as the Intel and Microsoft compilers on Windows -- Intel is pretty careful to maintain binary compatibility, and at least when I've tried it, it's always worked quite nicely.

For most other cases, the answer is no.

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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!