[vtk-developers] Casting vtkIntArray vs vtkIdTypeArray

David Gobbi david.gobbi at gmail.com
Sat Sep 18 19:29:25 EDT 2010


The g++ dynamic_cast has problems with shared object boundaries.
Specifically, if you dlopen() a shared object, you won't be able to do
any rtti between it and any other code unless special conditions are
met.

http://gcc.gnu.org/faq.html#dso

I have personally run into this with loading custom ITK plugins into
MATLAB.  If I load one plugin, it works fine, but I cannot load
multiple plugins and pass an ITK object pointer from one plugin to
another.  Everything works fine until the first time an rtti is
attempted, and then the program crashes.

  David


On Sat, Sep 18, 2010 at 4:20 PM, Bill Lorensen <bill.lorensen at gmail.com> wrote:
> David,
>
> Why are we using SafeDownCast rather than c++'s dynamic_cast?
>
> Bill
>
> On Sat, Sep 18, 2010 at 1:44 PM, David Gobbi <david.gobbi at gmail.com> wrote:
>> Just to make it clear to everyone on the list about SafeDownCast:
>>
>> SafeDownCast() allows or disallows casts based on the hierarchy and
>> nothing else.
>>
>> It refuses to cast a "vtkIdTypeArray *" to a "vtkIntArray *" is
>> because vtkIntArray is not a subclass of vtkIdTypeArray.  Also, as I
>> said before, it does not "convert" anything.  It merely reinterprets
>> one object pointer type as a different object pointer type.
>>
>>  David
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.vtk.org/mailman/listinfo/vtk-developers
>>
>>
>



More information about the vtk-developers mailing list