Skip to content

Commit a407b85

Browse files
authored
[cxx-interop] Document the C++14 requirement (#801)
This adds a note in the C++ interop docs about the minimum supported C++ standard.
1 parent 190bb21 commit a407b85

File tree

1 file changed

+21
-0
lines changed
  • documentation/cxx-interop/status

1 file changed

+21
-0
lines changed

documentation/cxx-interop/status/index.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,27 @@ building C++ code for Ubuntu.
8787
Mixed Swift and C++ code must use
8888
the same C++ standard library.
8989

90+
Using C++ interoperability requires a compiler with enabled support for the
91+
C++14 standard or a newer version. Swift allows you to change which version of
92+
the C++ standard it uses; however, the C++ library headers used from Swift must
93+
also conform to the selected C++ standard. When using bidirectional
94+
interoperability, programs need to be compiled with C++14 support, since the
95+
generated C++ interface for a Swift module uses C++14 features.
96+
97+
#### Customizing the C++ Standard Version
98+
99+
Here's how to set the version of the C++ standard used for interoperability
100+
by the Swift compiler:
101+
102+
- When compiling package dependencies, the C++ standard version can be
103+
customized in `Package.swift` using the `cxxLanguageStandard` parameter in
104+
your `Package(...)`.
105+
- For Xcode targets, you can choose the C++ standard used from the C++ Language
106+
Dialect setting in the Build Settings tab.
107+
- If you're using a different build system or invoking the `swiftc` Swift
108+
compiler directly from the command line, you can specify a C++ standard
109+
version with the `-Xcc -std=` option, for example, `-Xcc -std=c++20`.
110+
90111
## Supported C++ APIs
91112

92113
This section describes which C++ APIs are supported in Swift.

0 commit comments

Comments
 (0)