Skip to content
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

[SR-3024] Cannot use #if swift(>=3.0.1) compiler directive #45614

Closed
swift-ci opened this issue Oct 22, 2016 · 3 comments
Closed

[SR-3024] Cannot use #if swift(>=3.0.1) compiler directive #45614

swift-ci opened this issue Oct 22, 2016 · 3 comments
Labels
compiler directives Feature: compiler directives (#if, #warning, #error, etc.) compiler The Swift compiler in itself duplicate Resolution: Duplicates another issue feature A feature request or implementation improvement

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-3024
Radar None
Original Reporter schwa (JIRA User)
Type Bug
Status Resolved
Resolution Duplicate
Additional Detail from JIRA
Votes 0
Component/s
Labels Bug
Assignee None
Priority Medium

md5: 06b1747e0a82f0393913752d2fe143d0

duplicates:

  • SR-2908 Can't check sub minor version in #if swift(>=3.0.1)

Issue Description:

Swift 3.0.1 changes the UnsafePointer.withMemoryRebound method to take a closure that takes an UnsafeBuffer instead of an UnsafeMutablePointer - as was the case in Swift 3.0.

Because I have code that needs to be compiled in both Xcode 8 and 8.1 I would like to use the #if swift() compiler directive to detect Swift 3.0 vs Swift 3.0.1 and then conditionalise the code that uses withMemoryRebound to compile under both compilers.

Unfortunately the #if swift() directive does not allow me to detect the difference between the two versions and instead I get:

```
/Users/schwa/Projects/SwiftUtilities/Source/UnsafeBufferPointers.swift:52:17: error: expected named member of numeric literal
#if swift(>=3.0.1)
~~~ ^
```

I would expect either that 3.0.1 is not an API breaking release. Or that I am able to detect differences between compilers at a more fine grained level than I am provided with #if swift

(Also posted as rdar://28905799)

@belkadan
Copy link
Contributor

The intent of the pointer change was that it would be possible to write correct code in both language modes, since UnsafeMutablePointer<T> implicitly coerces to UnsafePointer<T> when used as an argument.

We can't really add a way to check for 3.0.1 at this point because 3.0GM didn't have that code, and it would still be a syntax error there. So this wouldn't solve your problem.

@atrick
Copy link
Member

atrick commented Oct 24, 2016

@belkadan, thank you for the comments. Just to confirm: correctly written code will work with both 3.0 and 3.0.1. Swift 3.0 was more permissible, but a trivial fix will work with both compilers.

@rxwei
Copy link
Member

rxwei commented Oct 24, 2016

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added improvement compiler The Swift compiler in itself feature A feature request or implementation duplicate Resolution: Duplicates another issue compiler directives Feature: compiler directives (#if, #warning, #error, etc.) and removed bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. labels Nov 12, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler directives Feature: compiler directives (#if, #warning, #error, etc.) compiler The Swift compiler in itself duplicate Resolution: Duplicates another issue feature A feature request or implementation improvement
Projects
None yet
Development

No branches or pull requests

5 participants