swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.69k stars 10.39k forks source link

[SR-485] C macros of the form ((long long)-1) should be imported #43102

Open 05262b81-54a9-4fe1-bf6a-96f8042de10e opened 8 years ago

05262b81-54a9-4fe1-bf6a-96f8042de10e commented 8 years ago
Previous ID SR-485
Radar rdar://problem/20462344
Original Reporter @lilyball
Type Bug
Environment Apple Swift version 2.1.1 (swiftlang-700.1.101.15 clang-700.1.81) Target: x86_64-apple-darwin15.2.0
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 3 | |Component/s | Compiler | |Labels | Bug, ClangImporter, Macros | |Assignee | None | |Priority | Medium | md5: 4f56b5e5a3db09cb27d77f8e3f9984fc

relates to:

Issue Description:

It turns out that NSURLResponseUnknownLength isn't exposed to Swift because the macro definition doesn't match Swift's rules for importable macros. The definition is:

#define NSURLResponseUnknownLength ((long long)-1)

This looks relatively straightforward, and should be simple enough that Swift can support. In general, any macro whose definition is the form ((SomeType)literal) should be importable.

swift-ci commented 7 years ago

Comment by Rick M (JIRA)

I'm having a similar problem with #define foo 1*2*3

swift-ci commented 3 years ago

Comment by Ky (JIRA)

This is necessary to complete the contract described in https://developer.apple.com/documentation/foundation/urlresponse/1413507-expectedcontentlength.

Without this, that contract cannot be fulfilled by API users