Fix build failure on modern macOS/Clang (Missing <experimental/coroutine>)#10
Open
marcinczeczko wants to merge 1 commit intomahilab:masterfrom
Open
Fix build failure on modern macOS/Clang (Missing <experimental/coroutine>)#10marcinczeczko wants to merge 1 commit intomahilab:masterfrom
marcinczeczko wants to merge 1 commit intomahilab:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR addresses a fatal compilation error encountered on modern macOS environments (specifically using Xcode 15+ and modern Clang) where the C++ Technical Specification (TS) header <experimental/coroutine> has been removed in favor of the standardized C++20 header.
The error during compilation
Changes:
Added a preprocessor check using __has_include to detect the presence of the standard header.
Implemented a conditional namespace alias to map std::coroutine_handle, std::suspend_always, and std::suspend_never into the std::experimental namespace.
This allows the existing codebase to remain unchanged while supporting modern C++20 compilers that have moved out of the "experimental" phase.
Maintains backward compatibility for older systems/Linux environments that still rely on the <experimental/coroutine> path.
Testing:
Verified on macOS (Sequoia/Sonoma) with CMake 4.x and Clang (Apple LLVM 15/16).
Confirmed that the fix resolves the 'experimental/coroutine' file not found error.
Notes: Requires the project to be compiled with the C++20 standard (e.g., -DCMAKE_CXX_STANDARD=20).
Steps done:
successfully compiled