Compiler c++ version flags supported

Hello,

I am trying to figure out what is supported and not supported in terms of C++ standard for library users. It might be in the doc and I might be missing something, but it is not clear to me what is and isn’t supported. C++ is backwards compatible (mostly), so my guess is that while ITK itself might not use the latest features of C++ and does not require the latest C++ standard, compiling it in that mode should still work.

In other words (I feel my question is unclear), ITK is C++11 or 14 (I think), but I want in my code to use C++17 or C++20 features. Can I compile ITK with the c++=xxx>=11 (or 14) flag and be confident that everything will be fine ?

I want to know because I have to plan my team’s path to upgrading C++ versions and I want to know if ITK is a limiting factor.

Thanks

Hello Ghyslain,

Welcome to the ITK Community! :sunny:

ITK currently requires C++11 as a minimum, but newer standards can be used, e.g. C++14, C++17, C++20.

Hope this helps,
Matt

1 Like

I think this means my understanding was correct. So long as it compiles without errors and the tests pass, then using a higher standard should not be problematic.

Thanks a lot for the quick response. Very much appreciated. :slight_smile:

2 Likes

@matt.mccormick Not C++20, yet, at least not without modification:

CMake Error at Modules/ThirdParty/VNL/src/vxl/CMakeLists.txt:34 (MESSAGE):
  CMAKE_CXX_STANDARD:STRING=20 not in know standards list

   11;14;17.


And it’s the same in upstream vxl: https://github.com/vxl/vxl/blob/master/CMakeLists.txt#L32

However, simply adding "20" to the list seems to work.
ITK configured, compiled and passed tests for my config:

100% tests passed, 0 tests failed out of 389

C++20 has not yet been officially published. When that happens, we will gladly accept PRs which add it to those lists.