- Proposal: SE-0181
- Author: Ankit Aggarwal
- Review Manager: Daniel Dunbar
- Status: Implemented (Swift 4.0)
- Decision Notes: Rationale
- Implementation: apple/swift-package-manager#1264
This proposal adds support for declaring the language standard for C and C++ targets in a SwiftPM package.
The C++ language standard is one of the most important build setting needed to compile C++ targets. We want to add some mechanism to declare it until we get the complete build settings feature, which is deferred from the Swift 4 release.
We will add support to the package manifest declaration to specify the C and C++ language standards:
let package = Package(
name: "CHTTP",
...
cLanguageStandard: .c89,
cxxLanguageStandard: .cxx11
)These settings will apply to all the C and C++ targets in the package. The
default value of these properties will be nil, i.e., a language standard flag
will not be passed when invoking the C/C++ compiler.
Once we get the build settings feature, we will deprecate these properties.
The C/C++ language standard will be defined by the enums below and updated as per the Clang compiler repository.
public enum CLanguageStandard {
case c89
case c90
case iso9899_1990
case iso9899_199409
case gnu89
case gnu90
case c99
case iso9899_1999
case gnu99
case c11
case iso9899_2011
case gnu11
}
public enum CXXLanguageStandard {
case cxx98
case cxx03
case gnucxx98
case gnucxx03
case cxx11
case gnucxx11
case cxx14
case gnucxx14
case cxx1z
case gnucxx1z
}There will be no impact on existing packages because this is a new API and the default behaviour remains unchanged.
We considered adding this property at target level but we think that will pollute the target namespace. Moreover, this is a temporary measure until we get the build settings feature.