1

I have this question regarding the exportation of STL containers in a Dll project.

I know when I have STL data members in class that I want to export, I will have a VS compiler warning C4251 about not having a dll-interface. However, I tried using PIMPL to hide these private data members, and I have methods that return STL containers. And this time, the compiler did not issue any warnings. Does this mean it is now safe to return STL containers as long as there is no STL containers as data members?

I’d appreciate it if someone could give me some insights to this. Thanks.

HzH
  • 51
  • 3
  • If the templates are not passed from outside of dll, or into dll from outside, there is no reason for this warning. Internally you can use any templates. If you export or get any templates from outside you should instantiate templates https://stackoverflow.com/questions/4933056/how-do-i-explicitly-instantiate-a-template-function – armagedescu Mar 19 '20 at 08:32

0 Answers0