Skip to content

Tracking issue to list all known issues related to C++ interoperability support in Swift 5.9 #66159

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

Open
hyp opened this issue May 26, 2023 · 2 comments
Assignees
Labels
c++ interop Feature: Interoperability with C++ swift 5.9

Comments

@hyp
Copy link
Contributor

hyp commented May 26, 2023

This issue contains a list of all known limitations and other issues related to C++ interoperability support in the Swift 5.9 release of Swift. Not known issues are not listed here, so if you see something please report a new issue.

Note: Swift 5.9 is still undergoing development, and therefore some limitations and issues listed here will be fixed before Swift 5.9 is release. Please see the following tracking issue you'd like to see which issues we plan on fixing in Swift 5.9.


Issues Related to Using C++ APIs in Swift 5.9

Some functions or member functions whose return type is not yet available in Swift, or not exported by the Clang module could appear to be available and callable from Swift, with the Never return type. Such functions should not be available in Swift, and should not be called : #64401 .

Default arguments in C++ functions are not mapped to default arguments in Swift functions or methods.

Functions inside inline namespaces must be accessed using the inline namespace qualifier from Swift due to: #58217 .

Issues Related to C++ Member Functions

C++ constant member functions that mutate the object using a mutable field cannot be annotated with SWIFT_MUTATING. This means that the user has no way to import it as mutating Swift method, and as such such member functions should generally not be called in Swift. This issue tracks the addition of SWIFT_MUTATING macro to the <swift/bridging> header: #66322.

Specifically on the Windows deployment platform, some member functions might be dispatched incorrectly: #66326

Issues Related to Accessing Inherited Members

Swift compiler might introduce ambiguous method overloads when adding a C++ member from a base a C++ class to the Swift type that represents the C++ class or structure. This issue tracks the clarification of related rules which should resolve the problem, and gives an example of when such issue might occur: #66323

Issues Related to C or Objective-C compatibility

Objective-C options sets, like NSTrackingArea import incorrectly when C++ interoperability is enabled: #65885

Use of some Objective-C Foundation functions, like URL.bookmark() might lead to linking errors: #66501

A trivial C++ structure or class that has only Objective-C ARC object pointers as fields can be incorrectly passed to an Objective-C method call when C++ interop is enabled (on Intel): #61929 .

On Linux, you cannot import Foundation when C++ interop is enabled: #64457

Known Compiler Crashes In Swift Related to C++ Interoperability


Issues Related to Using Swift APIs in C++

Swift functions and methods are exposed to C++ using just their base name, and argument labels aren't factored into the C++ function name. Only one function / method with the same base name and same number of parameters is exposed to C++. For example, given the following two functions:

func print(company: Int) {}
func print(person: String) {}

Only one of them is available in C++.

Issues Related to Using Swift Structures or Enumerations in C++

Swift structures and enumerations currently can't use the copy-assignment operator in C++, i.e. they can't be reassigned after they're initialized: #66324.

Swift structures and enumerations cannot be moved in C++. That is, you can't use std::move on a Swift structure or enumeration to move a value to a new value using a move constructor or a move assignment operator.

Issues Related to Using Swift Generics in C++

Swift generic structure or enumeration might fail to work with the Swift Int type as a generic type parameter in C++: #63452 .


Issues Related to Swift Package Manager Support For C++ Interoperability


Issues Related to IDE Support

Code-completion for C++ namespace members in Swift is not yet supported: #65736 .

@hyp hyp added the swift 5.9 label May 26, 2023
@hyp hyp self-assigned this May 26, 2023
@AnthonyLatsis AnthonyLatsis added the c++ interop Feature: Interoperability with C++ label May 26, 2023
@mickeyl
Copy link

mickeyl commented Jun 9, 2023

Is support for default arguments a target or not?

@hyp
Copy link
Contributor Author

hyp commented Jun 9, 2023

Is support for default arguments a target or not?

Not for Swift 5.9

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++ swift 5.9
Projects
None yet
Development

No branches or pull requests

3 participants