Windows version number support for the @available attribute #73655
Labels
availability
The @available attribute and availability checking in general
compiler
The Swift compiler in itself
feature
A feature request or implementation
Frontend
Area → compiler: Frontend
Windows
Platform: Windows
Motivation
The
@available
enables warnings and deprecation of functionality based on OS version. This is currently not implemented on Windows:(I am building against a version of windows greater than this number. The issue also happens when specifying version
1.0.0
or any other value)Proposed solution
Windows has well defined version numbers of the form
10.0.<buildnumber>
as described on Wikipedia: https://en.wikipedia.org/wiki/Windows_10_version_history . This scheme also supports version numbers prior and subsequent to Windows 10.On Windows,
@available
should test whether the Windows version we're building for is greater or equal to the specified version number. As a first approximation, this could use the version number of the Windows SDK we're building for (-windows-sdk-version
), but ideally we could also specify a target version number separately. Theif #available
syntax should also be supported on Windows.Alternatives considered
As a workaround, it's possible to do runtime checks.
Additional information
No response
The text was updated successfully, but these errors were encountered: