itk doesn't work with c++17

(Eliah Ninyo) #1

hello,
i’m using the itkImageAlgorithm H file and i get the following error:
itkImageAlgorithm.h:193: error: C2143: syntax error: missing ‘,’ before ‘<’

this is the code:
/** Unary functor just for static_cast operator */
template<typename TInputType, typename TOutputType>
struct StaticCast
: public std::unary_function<TInputType,TOutputType>
{
TOutputType operator() (const TInputType i) { return static_cast(i); }
};

any suggestions?

(Dženan Zukić) #2

Which version of ITK are you trying to use it with, 4.13.2 or 5.0.0? Also, I don’t think expression static_cast(i) is valid in any version of C++.

(Eliah Ninyo) #3

hi,
i’m using ITK 4.13.2 and not 5.

the issue is in ITK code and not my code. in my project i simply tried to set the c++ to be 17 instead of 11 and this is one of the many errors i got.

do you have a project that uses ITK 4.13.2 with c++17 as the compiler?

(Francois Budin) #4

The std function called in ITK on the line causing an issue has been removed in C++17 (see here). This line has been removed in ITKv5, so to solve your problem you can either move to ITKv5 or patch ITKv4.13.2 for your project and simply remove this line of code.

1 Like