Skip to content

[cxx-interop] Simplify std::string construction in the overlay #83727

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 15, 2025

Conversation

egorzhdan
Copy link
Contributor

libc++ provides a 2-parameter constructor of std::string, so we can apply the logic under #if os(Windows) on Apple platforms too.

This avoids deserialization issues when building some complex projects that are still under investigation.

rdar://145939013

libc++ provides a 2-parameter constructor of `std::string`, so we can apply the logic under `#if os(Windows)` on Apple platforms too.

This avoids deserialization issues when building some complex projects that are still under investigation.

rdar://145939013
@egorzhdan egorzhdan added the c++ interop Feature: Interoperability with C++ label Aug 14, 2025
@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

Copy link
Contributor

@j-hui j-hui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

Comment on lines +30 to +31
// Note that we might be compiling with libc++ on Linux, even if it's not
// the default stdlib on a particular distro.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wondering: is there any way to detect which CxxStdlib we're compiling against/importing? Though I'm not sure that'll really help us solve the issue here, since we probably won't actually know that information when we compile the overlay.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not at the moment, no.
Ideally we would extend something like if #targetEnvironment or if #available to allow checking for the C++ stdlib that's being used, but that isn't implemented yet.

@egorzhdan egorzhdan merged commit 0f963d7 into swiftlang:main Aug 15, 2025
3 checks passed
@egorzhdan egorzhdan deleted the egorzhdan/std-string-ctor branch August 15, 2025 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ interop Feature: Interoperability with C++
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants