[ITK-dev] [slicer-devel] Workaround for dynamic_cast on Mac OSX

Lowekamp, Bradley (NIH/NLM/LHC) [C] blowekamp at mail.nih.gov
Mon Nov 14 14:18:55 EST 2016


Matt,

I believe that GCC 4.1 also had a very similar problem to what is occurring in with Apple Clang now.

That looks like a good example for the problem.

The replacement of all dynamic_casts of all itk::Objects is one approach. Here is a few others:

1) Make an explicit instantiation library with the ITK classes part of the shared libraries' interfaces.
2) Just compile the problematic libraries with default visibility.
3) Restore the functionality of the old “WrapITK” Explicit language/feature to explicitly instantiate all of ITK.
4) Write an entire library which fully encapsulates the ITK templated interface and used it’s own object for the visibility specified API :)

It’s interesting to note that Slicer CLI interface does not contain ITK templated objects. Does Slicer use ITK objects any where in it’s public API’s?

HTH,
Brad

> On Nov 11, 2016, at 6:01 PM, Matt McCormick <matt.mccormick at kitware.com> wrote:
> 
> Here are the tests:
> 
>  http://review.source.kitware.com/#/c/21755/
> 
> where reasonable export specification is added in both ITK and the
> client libraries. But, dynamic_cast fails on OSX:
> 
>  https://open.cdash.org/testDetails.php?test=499059765&build=4637669
> 
> 
> Matt
> 
> On Thu, Nov 10, 2016 at 3:21 PM, Johnson, Hans J <hans-johnson at uiowa.edu> wrote:
>> I agree with Marcus.  At least until it is very clear that not using dynamic_cast is the only solution to a broken compiler, I am very weary of “doing what works today”.
>> 
>> Hans
>> 
>> 
>> --
>> 
>> 
>> On 11/10/16, 1:11 PM, "Insight-developers on behalf of Marcus D. Hanwell" <insight-developers-bounces at itk.org on behalf of marcus.hanwell at kitware.com> wrote:
>> 
>>    On Tue, Nov 8, 2016 at 5:01 PM, Matt McCormick
>>    <matt.mccormick at kitware.com> wrote:
>>> Hi folks,
>>> 
>>> As we have wrestled with in Slicer, along with other applications
>>> where ITK is used in multiple shared libraries, dynamic_cast can fail
>>> on Mac OSX.
>>> 
>>> I summarized the cause of the problem and steps for the proposed solution here:
>>> 
>>>  https://issues.itk.org/jira/browse/ITK-3490
>>> 
>>> Feedback is welcome. The effort is targeted for the ITK 4.11.0 release.
>>> 
>>    From the issue it is not clear to me why you can't fix the symbol
>>    visibility issues, or which of these cases it causing the breakage.
>>    Reading the linked blog post it seems like Apple/Clang is doing the
>>    right thing, and C++ libraries must be careful to use consistent
>>    symbol visibility.
>> 
>>    I would be interested in further details on which case or cases are
>>    causing dynamic_cast to fail, and why using consistent symbol
>>    visibility in the interfaces is not feasible/possible.
>> 
>>    Thanks,
>> 
>>    Marcus
>>    _______________________________________________
>>    Powered by www.kitware.com
>> 
>>    Visit other Kitware open-source projects at
>>    http://www.kitware.com/opensource/opensource.html
>> 
>>    Kitware offers ITK Training Courses, for more information visit:
>>    http://kitware.com/products/protraining.php
>> 
>>    Please keep messages on-topic and check the ITK FAQ at:
>>    http://www.itk.org/Wiki/ITK_FAQ
>> 
>>    Follow this link to subscribe/unsubscribe:
>>    http://public.kitware.com/mailman/listinfo/insight-developers
>> 
>> 
> _______________________________________________
> slicer-devel mailing list
> slicer-devel at bwh.harvard.edu
> http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
> To unsubscribe: send email to slicer-devel-request at bwh.harvard.edu with unsubscribe as the subject
> http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ



More information about the Insight-developers mailing list