3 Mar
2006
3 Mar
'06
7:57 a.m.
adharankar@verizon.net wrote:
What is wrong in assigning a smart/shared_ptr pointer in C++ code to a struct which may then be passed to a C code?
There is no safe way to pass any non-POD type to C code. In your example, this means both the shared_ptr object and the pointed-to A object. You need to ensure the lifetime of the pointer manually, and you need to extract the raw pointer and pass that to the C code. You also need to make it point to a POD type. Sebastian Redl