RE: [Boost-users] Using shared_ptr across shared library boundary
Edward Diener wrote:
Is there any problem with using shared_ptr and passing an instance of it to a function in another shared library, such as a DLL under Windows ? Does the reference count get updated correctly when the copy is passed to a DLL function, so that when the last shared_ptr in either the original module or the DLL goers out of scope, the actual pointer is correctly deleted ? I've been using it successfully across DLL boundaries with no problems.
The biggest caveat is to ensure you are using the DLL version of the C Runtime library. If you use the static library version, then each DLL will have its own heap, and a pointer *must* be deallocated in the same DLL in which it was allocated. -- Jim Hyslop Senior Software Designer Leitch Technology International Inc. (http://www.leitch.com) Columnist, C/C++ Users Journal (http://www.cuj.com/experts)
"Jim.Hyslop"
Edward Diener wrote:
Is there any problem with using shared_ptr and passing an instance of it to a function in another shared library, such as a DLL under Windows ? Does the reference count get updated correctly when the copy is passed to a DLL function, so that when the last shared_ptr in either the original module or the DLL goers out of scope, the actual pointer is correctly deleted ? I've been using it successfully across DLL boundaries with no problems.
The biggest caveat is to ensure you are using the DLL version of the C Runtime library. If you use the static library version, then each DLL will have its own heap, and a pointer *must* be deallocated in the same DLL in which it was allocated.
Please stop; this is misinformation. -- Dave Abrahams Boost Consulting www.boost-consulting.com
participants (2)
-
David Abrahams
-
Jim.Hyslop