# Shall we start using C++17 at the master branch?

**URL:** <https://discourse.itk.org/t/shall-we-start-using-c-17-at-the-master-branch/5828>\
**Category:** Engineering\
**Created:** [March 23, 2023, 3:33pm UTC](https://discourse.itk.org/t/shall-we-start-using-c-17-at-the-master-branch/5828 "2023-03-23T15:33:26Z")\
**Posts on this page:** 17\
**Page:** 2

<div class="post-metadata">

**Author:** ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)\
**Post date:** [April 4, 2024, 6:07pm UTC](https://discourse.itk.org/t/shall-we-start-using-c-17-at-the-master-branch/5828/21 "2024-04-04T18:07:23Z")

</div>

> [@blowekamp](#):
>
> Another release candidate? I am not sure why actually releases are not occurring.

As was discussed with the last release candidate, there were a number of outstanding, critical contributions related to DICOM support that had not been integrated. These have now been integrated. 5.4 RC 3 will be the last release candidate.

> [@blowekamp](#):
>
> More specific to the point, I would expect the requirements for the next release (non-RC) to be set, and after the release the build requirements may change.

Yes, changes to build requirements should not be made until after v5.4.0.

---

<div class="post-metadata">

**Author:** ![Niels\_Dekker](https://discourse.itk.org/letter_avatar_proxy/v4/letter/n/9d8465/32.png) [@Niels\_Dekker](https://discourse.itk.org/u/Niels_Dekker)\
**Post date:** [May 13, 2025, 1:39pm UTC](https://discourse.itk.org/t/shall-we-start-using-c-17-at-the-master-branch/5828/22 "2025-05-13T13:39:43Z")

</div>

Another year later, would it now be acceptable to use `std::filesystem` in ITK?

Looks like it is supported “out of the box” from GCC 9.1 and from LLVM 9.0 (for clang). Older compiler versions would require an extra compiler flag. According to [cppreference.com/w/cpp/filesystem](https://en.cppreference.com/w/cpp/filesystem):

> ### Notes
> 
> Using this library may require additional compiler/linker options. GNU implementation prior to 9.1 requires linking with `-lstdc++fs` and LLVM implementation prior to LLVM 9.0 requires linking with `-lc++fs`.

---

<div class="post-metadata">

**Author:** ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)\
**Post date:** [May 13, 2025, 1:58pm UTC](https://discourse.itk.org/t/shall-we-start-using-c-17-at-the-master-branch/5828/23 "2025-05-13T13:58:55Z")

</div>

> [@Niels\_Dekker](#):
>
> Another year later, would it now be acceptable to use `std::filesystem` in ITK?

A blocker is the Python binaries require specific OSX deployment targets for binary compatibility. And to use std::filesystem in particular require OSX 10.15 deployment target, I believe the current deployment targets may be 10.13 at the newest, but I wasn’t able to quickly find an official reference…yet. However, other C++17 features can be used with out the requirement for the newer OSX SDK.

---

<div class="post-metadata">

**Author:** ![seanm](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/a88e4f/32.png) [@seanm](https://discourse.itk.org/u/seanm)\
**Post date:** [May 13, 2025, 6:00pm UTC](https://discourse.itk.org/t/shall-we-start-using-c-17-at-the-master-branch/5828/24 "2025-05-13T18:00:32Z")

</div>

Yes, annoyingly, std::filesystem requires macOS 10.15 at runtime. I believe this is because the version of STL shipped with macOS only started supporting std::filesystem as of 10.15. So even if you use newer macOS and clang to build your code, it won’t _run_ on anything older than 10.15.

My oldest bot building ITK nightly is for 10.13.

Personally, I’d be OK with increasing ITK 6’s minimum from 10.13 to 10.15 at this point. (I would certainly much rather that than dropping Intel support for example!)

Sean

---

<div class="post-metadata">

**Author:** ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)\
**Post date:** [May 13, 2025, 6:14pm UTC](https://discourse.itk.org/t/shall-we-start-using-c-17-at-the-master-branch/5828/25 "2025-05-13T18:14:19Z")

</div>

> [@seanm](#):
>
> Personally, I’d be OK with increasing ITK 6’s minimum from 10.13 to 10.15 at this point. (I would certainly much rather that than dropping Intel support for example!)

O, these are related. The first OS to support that ARM was 11 Big Sur, so these issues are related 🙂 Dropping intel implies 11 as the minimum supported version.

---

<div class="post-metadata">

**Author:** ![dchen](https://discourse.itk.org/user_avatar/discourse.itk.org/dchen/32/34_2.png) [@dchen](https://discourse.itk.org/u/dchen)\
**Post date:** [May 13, 2025, 6:57pm UTC](https://discourse.itk.org/t/shall-we-start-using-c-17-at-the-master-branch/5828/26 "2025-05-13T18:57:23Z")

</div>

We (the NIAID SimpleITK folks) are still on 10.14. 10.15 hasn’t been approved by management. One of us is still using an Intel Mac as his main laptop. 🤦‍♂️

---

<div class="post-metadata">

**Author:** ![seanm](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/a88e4f/32.png) [@seanm](https://discourse.itk.org/u/seanm)\
**Post date:** [May 13, 2025, 8:06pm UTC](https://discourse.itk.org/t/shall-we-start-using-c-17-at-the-master-branch/5828/27 "2025-05-13T20:06:06Z")

</div>

Sure, but (hypothetically) requiring macOS 11 as ITK’s minimum does not imply Intel support should be dropped. There are Intel Macs that run the very newest macOS 15.

Alas, the Mac world is not like the Linux world, where you can update even quite old PCs to run the newest Linux. macOS drops hardware support (too) quickly, and so users often can’t upgrade their macOS even if they wanted to.

---

<div class="post-metadata">

**Author:** ![jamesobutler](https://discourse.itk.org/user_avatar/discourse.itk.org/jamesobutler/32/1807_2.png) [@jamesobutler](https://discourse.itk.org/u/jamesobutler)\
**Post date:** [May 14, 2025, 1:14am UTC](https://discourse.itk.org/t/shall-we-start-using-c-17-at-the-master-branch/5828/28 "2025-05-14T01:14:30Z")

</div>

At the application level of 3D Slicer (which uses ITK) the `CMAKE_OSX_DEPLOYMENT_TARGET` is set to 13.0 as providing support for OS versions that were no longer receiving security updates is not worth the effort for latest development. macOS 13.0 deployment target sets support for hardware ~8 years old and newer to run the latest application version. This seems appropriate as it relates to supporting a MacBook Pro all the way from 2017.

> <https://github.com/Slicer/Slicer/commit/ba3a9fdc04c9f4fc47cad331f9160b6d7a0beded>
>
> Although Apple does not list an end-of-support date, macOS Monterey (12.0) last …received a security update in July 2024. https://endoflife.date/macos
> 
> macOS Ventura (13) hardware requirements
> https://support.apple.com/en-us/102861

Similarly with Windows 10 consumer versions going EOL later this year, Windows 11 requires CPUs from about Intel 8th gen and newer which also corresponds to hardware from about 2017 and newer.

---

<div class="post-metadata">

**Author:** ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)\
**Post date:** [May 14, 2025, 1:06pm UTC](https://discourse.itk.org/t/shall-we-start-using-c-17-at-the-master-branch/5828/29 "2025-05-14T13:06:13Z")

</div>

> [@dchen](#):
>
> 10.15 hasn’t been approved by management.

Why such a long delay? If you don’t know, can you speculate?

---

<div class="post-metadata">

**Author:** ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)\
**Post date:** [May 14, 2025, 3:03pm UTC](https://discourse.itk.org/t/shall-we-start-using-c-17-at-the-master-branch/5828/30 "2025-05-14T15:03:04Z")

</div>

I believe he meant 15, not 10.15.

---

<div class="post-metadata">

**Author:** ![dchen](https://discourse.itk.org/user_avatar/discourse.itk.org/dchen/32/34_2.png) [@dchen](https://discourse.itk.org/u/dchen)\
**Post date:** [May 14, 2025, 3:36pm UTC](https://discourse.itk.org/t/shall-we-start-using-c-17-at-the-master-branch/5828/31 "2025-05-14T15:36:35Z")

</div>

Oh you’re right. I got confused, since they stop using 10.XX versions.

---

<div class="post-metadata">

**Author:** ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)\
**Post date:** [May 14, 2025, 3:40pm UTC](https://discourse.itk.org/t/shall-we-start-using-c-17-at-the-master-branch/5828/32 "2025-05-14T15:40:09Z")

</div>

Well then requiring MacOS 10.15 as the minimum should not be so outrageous?

---

<div class="post-metadata">

**Author:** ![seanm](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/a88e4f/32.png) [@seanm](https://discourse.itk.org/u/seanm)\
**Post date:** [May 14, 2025, 3:46pm UTC](https://discourse.itk.org/t/shall-we-start-using-c-17-at-the-master-branch/5828/33 "2025-05-14T15:46:30Z")

</div>

> Well then requiring MacOS 10.15 as the minimum should not be so outrageous?

It’s OK for me at this point. Our current app still supports 10.13, but our next major release is upping that to 10.15.

---

<div class="post-metadata">

**Author:** ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)\
**Post date:** [May 14, 2025, 3:58pm UTC](https://discourse.itk.org/t/shall-we-start-using-c-17-at-the-master-branch/5828/34 "2025-05-14T15:58:07Z")

</div>

Here some documentation regarding setting the target deployment target when building Python binaries: [Modern C++ standards - cibuildwheel](https://cibuildwheel.pypa.io/en/stable/cpp_standards/#macos-and-deployment-target-versions)

I suppose I am conservative when building binaries, and set the target version to match that of the [python.org](http://python.org) target version.

---

<div class="post-metadata">

**Author:** ![imikejackson](https://discourse.itk.org/user_avatar/discourse.itk.org/imikejackson/32/35_2.png) [@imikejackson](https://discourse.itk.org/u/imikejackson)\
**Post date:** [May 20, 2025, 12:45pm UTC](https://discourse.itk.org/t/shall-we-start-using-c-17-at-the-master-branch/5828/35 "2025-05-20T12:45:05Z")

</div>

You could always substitute in “GHC\_FileSystem” which I think is what made its way to std::filesystem. The easiest way is to just use a #ifdef to figure out if you are on **APPLE** and then just alias the namespaces to “fs” so:

```auto
#ifdef EbsdLib_USE_GHC_FILESYSTEM
#include <ghc/filesystem.hpp>
namespace fs = ghc::filesystem;
#else
#include <filesystem>
namespace fs = std::filesystem;
#endif

```

Then in our CMakeLists.txt file we have:

```auto
#-------------------------------------------------------------------------------
# Determine if we need the ghcFilesystem library
#-------------------------------------------------------------------------------
set(EbsdLib_USE_GHC_FILESYSTEM OFF)

if(APPLE)
  execute_process(COMMAND uname -v OUTPUT_VARIABLE DARWIN_VERSION)
  string(REGEX MATCH "[0-9]+" DARWIN_VERSION ${DARWIN_VERSION})
  if(DARWIN_VERSION VERSION_LESS 19)
    message(STATUS "The current macOS System is too old to compile and will fail. Please set the EbsdLib_USE_GHC_FILESYSTEM=ON variable to allow Ebsdlib to compile")
  endif()
  message(STATUS "EbsdLib: DARWIN_VERSION ${DARWIN_VERSION}")
  message(STATUS "EbsdLib: CMAKE_OSX_DEPLOYMENT_TARGET: ${CMAKE_OSX_DEPLOYMENT_TARGET}")
  if(NOT "${CMAKE_OSX_DEPLOYMENT_TARGET}" STREQUAL "" )
    if(CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS 10.15)
      message(STATUS "EbsdLib: CMAKE_OSX_DEPLOYMENT_TARGET less than 10.15. Enabling EbsdLib_USE_GHC_FILESYSTEM")
      set(EbsdLib_USE_GHC_FILESYSTEM ON)
    endif()
  endif()
endif()
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux" AND ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0)
  set(EbsdLib_USE_GHC_FILESYSTEM ON)
endif()

message(STATUS "EbsdLib: EbsdLib_USE_GHC_FILESYSTEM: ${EbsdLib_USE_GHC_FILESYSTEM}")

if(EbsdLib_USE_GHC_FILESYSTEM)
  find_package(ghcFilesystem REQUIRED NAMES ghc_filesystem ghcFilesystem)
endif()

```

And I remember that working fairly well.

If you just move to a MacOS deployment of MacOS version 11.0 then you don’t need any of this. If we are talking in the context of ITK 6 then I think it is time to leave some of these ancient systems behind.

---

<div class="post-metadata">

**Author:** ![Niels\_Dekker](https://discourse.itk.org/letter_avatar_proxy/v4/letter/n/9d8465/32.png) [@Niels\_Dekker](https://discourse.itk.org/u/Niels_Dekker)\
**Post date:** [May 21, 2025, 12:14pm UTC](https://discourse.itk.org/t/shall-we-start-using-c-17-at-the-master-branch/5828/36 "2025-05-21T12:14:08Z")

</div>

Thanks to you all for your feedback so far. This is very helpful.

I don’t have an urgent need to use `std::filesystem` right away, within the implementation of ITK. It’s only that we are considering to use it in the implementation of [elastix](https://github.com/SuperElastix/elastix). Specifically for [ENH: Add IMPACT Similarity Metric to Elastix by vboussot · Pull Request #1311 · SuperElastix/elastix · GitHub](https://github.com/SuperElastix/elastix/pull/1311) Elastix usually follows ITK, regarding the use of C++ features. (elastix also uses ITK internally.) So in general, we are a bit reluctant to start using C++ features in elastix, that are not yet allowed in ITK. But I think now that it would be OK for elastix to use `std::filesystem`.

---

<div class="post-metadata">

**Author:** ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)\
**Post date:** [May 28, 2025, 11:29pm UTC](https://discourse.itk.org/t/shall-we-start-using-c-17-at-the-master-branch/5828/37 "2025-05-28T23:29:49Z")

</div>

Related GitHub issue for macOS 15 deployment target:

> <https://github.com/InsightSoftwareConsortium/ITK/issues/5369>
>
> \### \*\*Rationale\*\*
> 
> \#### \*\*1. Apple’s Deprecation of Older macOS Versions\*\*
> 
> \- ma…cOS 10.15 (Catalina) loses \*\*security support on June 30, 2025\*\*, creating vulnerabilities for users on older systems\[^2\].
> \- Current ITK Python builds default to macOS 10.9 (Intel), macOS 10.11 (ARM), which are no longer receiving security updates\[^2\]\[^7\].
> 
> 
> \#### \*\*2. C++17 and SDK Compatibility\*\*
> 
> \- Full C++17 support (e.g., \`\<filesystem\>\`, \`\<variant\>\`) requires \*\*macOS 10.15 or newer\*\*\[^4\]\[^8\]\[^10\].
> \- Legacy deployment targets (e.g., 10.9–10.13) force workarounds like \`\<experimental/filesystem\>\`, increasing maintenance complexity\[^4\]\[^5\].
> \- Modern compilers (Xcode 15+) and SDKs increasingly enforce stricter compatibility checks, causing build failures on older targets\[^6\]\[^9\].
> 
> 
> \#### \*\*3. Compiler Optimizations\*\*
> 
> \- Newer macOS SDKs enable advanced optimizations (e.g., autovectorization, LTO) that are restricted on older deployment targets.
> 
> \#### \*\*4. Maintenance Burden\*\*
> 
> \- Third-party projects (e.g., PyTorch) are dropping support for macOS \<10.15, creating compatibility gaps\[^1\]\[^6\]\[^10\].
> 
> \---
> 
> \### \*\*Proposed Changes\*\*
> 
> 1. \*\*Update Minimum Deployment Target\*\*
> - Set \`MACOSX\_DEPLOYMENT\_TARGET\` to \*\*10.15\*\* for ITK 6.x in Python wheels.
> - Document 10.15 as the new baseline for macOS support.
> 2. \*\*CI/CD Pipeline Updates\*\*
> - Update macOS runners with to \`macos-15\`+ runners\[^1\]\[^9\].
> 3. \*\*C++17 Modernization\*\*
> - Replace deprecated headers (e.g., \`\<experimental/filesystem\>\`) with standard C++17 equivalents.
> 
> \---
> 
> \### \*\*Impact Mitigation\*\*
> 
> \- \*\*LTS Branch\*\*: Maintain ITK 5.x with macOS 10.9 support for legacy workflows \[^1\]\[^3\].
> 
> 
> \---
> 
> \### \*\*Supporting Data\*\*
> 
> | Key Point | Source |
> | :-- | :-- |
> | macOS 10.15 security EOL: June 2025 | \[^2\]\[^7\] |
> | C++17 \`\<filesystem\>\` requires 10.15 | \[^4\]\[^8\]\[^10\] |
> | Xcode 15+ enforces 10.13+ targets | \[^6\]\[^9\] |
> 
> 
> \---
> 
> \### \*\*Request for Feedback\*\*
> 
> 1. Are there critical use cases requiring macOS \<10.15?
> 2. Concerns about dependency compatibility (e.g., hardware drivers)?
> 
> \*Proposed timeline: Target ITK 6.0 (2025) to align with macOS 10.15’s security EOL.\*
> 
> CC @seanm @blowekamp @hjmjohnson @cookpa @imikejackson @SimonRit @jcfr 
> 
> \[^1\]: https://github.com/InsightSoftwareConsortium/ITK/issues/5326
> 
> \[^2\]: https://access.tufts.edu/macos-1015-support-ends-june-30-2025-take-action-now
> 
> \[^3\]: https://computercity.com/desktops/mac/how-long-will-intel-macs-be-supported
> 
> \[^4\]: https://cibuildwheel.pypa.io/en/stable/cpp\_standards/
> 
> \[^5\]: https://forum.juce.com/t/fix-for-using-c-11-features-with-osx-10-7-deployment-target/25247
> 
> \[^6\]: https://github.com/apple/swift/issues/68163
> 
> \[^7\]: https://discussions.apple.com/thread/255690857
> 
> \[^8\]: https://forum.juce.com/t/c-17-minimum-deployment-target/32109
> 
> \[^9\]: https://github.com/sparkle-project/Sparkle/issues/2186
> 
> \[^10\]: https://github.com/nlohmann/json/issues/3156
> 
> \[^11\]: https://discussions.apple.com/thread/256008545
> 
> \[^12\]: https://endoflife.date/macos
> 
> \[^13\]: https://www.reddit.com/r/MacOS/comments/1djinz3/how\_long\_will\_the\_10th\_gen\_intel\_mba\_2020\_be/
> 
> \[^14\]: https://support.apple.com/en-us/100100
> 
> \[^15\]: https://developer.apple.com/xcode/cpp/
> 
> \[^16\]: https://github.com/transmission/transmission/issues/3302
> 
> \[^17\]: https://stackoverflow.com/questions/51288230/how-do-i-enable-c17-in-xcode-for-mac-osx
> 
> \[^18\]: https://github.com/xianyi/OpenBLAS/issues/1580
> 
> \[^19\]: https://developer.apple.com/documentation/xcode/build-settings-reference
> 
> \[^20\]: https://setapp.com/how-to/full-list-of-all-macos-versions
> 
> \[^21\]: https://discussions.apple.com/thread/256009912
> 
> \[^22\]: https://arstechnica.com/gadgets/2024/06/the-case-for-and-against-macos-15-sequoia-being-the-final-release-for-intel-macs/
> 
> \[^23\]: https://stackoverflow.com/questions/72891223/what-should-i-do-to-change-the-macosx-deployment-target-when-build-flutter-macos
> 
> \[^24\]: https://forum.qt.io/topic/81167/qt-static-compile-macos-deployment-target
> 
> \[^25\]: https://github.com/rust-lang/rust/issues/129432
> 
> \[^26\]: https://stackoverflow.com/questions/46821229/xcode-9-macos-deployment-target-with-c-giving-error
> 
> \[^27\]: https://www.reddit.com/r/gamedev/comments/1gr5j2g/can\_i\_compile\_and\_run\_cc\_on\_macos\_1013\_if\_yes\_how/
> 
> \[^28\]: https://anyware.hp.com/documentation/components/client-sdk-for-macos/release-notes
> 
> \[^29\]: https://firebase.google.com/support/release-notes/ios

[Previous page](https://discourse.itk.org/t/shall-we-start-using-c-17-at-the-master-branch/5828.md?page=1)
