Problems when dllimport is not used by the client of the exported class?

Apart from method calls that are not optimized, are there other problems?

The difference I noticed is that the ones generated by the default compiler method (e.g. operator =) in the class appear either in the exporting dll (if dllimport is used by the client) or in the client binary (if dllimport is not used). In this latter case, it is almost as if part of the class were defined in the dll and part in the binary client. Are there any problems with this?

+1


source to share


1 answer


I am assuming that in both cases the implementation of the class is in the DLL, is that correct?

The main problem I see in this scenario is that if an assignment operator using the compiler allocates any memory, even indirectly by calling other copy constructors or assignment operators, the memory could potentially be allocated on the "wrong" heap (client heap instead DLL heaps where they will be allocated if the target statement was in a DLL). This can lead to memory leaks and sometimes it is difficult to debug the problem.



However, if your objects are "trivial enough" you don't need to write your own copy constructors and assignment operators (and destructors - see the three rules ), you can easily avoid this, especially if you're just throwing a couple of PODs.

+1


source







All Articles