How to expose STL list over DLL boundary?

后端 未结 3 795
情话喂你
情话喂你 2021-02-02 02:42

I have a DLL which needs to access data stored in STL containers in the host application. Because C++ has no standard ABI, and I want to support different compilers, the interf

3条回答
  •  名媛妹妹
    2021-02-02 03:31

    the interface between the application and DLL basically has to remain plain-old-data.

    Not necessarily. You have to be sure that the same compiler version is used. Also, build settings that impact the layout of the STL objects is exactly the same between the dll and application.

    If you were to release the dll out into the wild, you are right to be concerned with exposing STL across dll boundaries. If, however, everything is under your control and purely internal (or if you can rigidly enforce 3rd party build settings/compiler) you should be fine.

提交回复
热议问题