Skip to content

Commit e72f819

Browse files
authored
Merge pull request #39641 from atrick/swift-to-c-pointer-changelog
2 parents 63839ac + f6009e6 commit e72f819

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

CHANGELOG.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,31 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
66
Swift 5.6
77
---------
88

9+
* [SE-0324][]:
10+
11+
Relax diagnostics for pointer arguments to C functions. The Swift
12+
compiler now accepts limited pointer type mismatches when directly
13+
calling functions imported from C as long as the C language allows
14+
those pointer types to alias. Consequently, any Swift
15+
`Unsafe[Mutable]Pointer<T>` or `Unsafe[Mutable]RawPointer` may be
16+
passed to C function arguments declared as `[signed|unsigned] char
17+
*`. Swift `Unsafe[Mutable]Pointer<T>` can also be passed to C
18+
function arguments with an integer type that differs from `T` only
19+
in its signedness.
20+
21+
For example, after importing a C function declaration:
22+
```c
23+
long long decode_int64(const char *ptr_to_int64);
24+
```
25+
Swift can now directly pass a raw pointer as the function argument:
26+
```swift
27+
func decodeAsInt64(data: Data) -> Int64 {
28+
data.withUnsafeBytes { (bytes: UnsafeRawBufferPointer) in
29+
decode_int64(bytes.baseAddress!)
30+
}
31+
}
32+
```
33+
934
* [SE-0315][]:
1035

1136
Type expressions and annotations can now include "type placeholders" which
@@ -8697,6 +8722,7 @@ Swift 1.0
86978722
[SE-0313]: <https://github.com/apple/swift-evolution/blob/main/proposals/0313-actor-isolation-control.md>
86988723
[SE-0315]: <https://github.com/apple/swift-evolution/blob/main/proposals/0315-placeholder-types.md>
86998724
[SE-0316]: <https://github.com/apple/swift-evolution/blob/main/proposals/0316-global-actors.md>
8725+
[SE-0324]: <https://github.com/apple/swift-evolution/blob/main/proposals/0324-c-lang-pointer-arg-conversion.md>
87008726

87018727
[SR-75]: <https://bugs.swift.org/browse/SR-75>
87028728
[SR-106]: <https://bugs.swift.org/browse/SR-106>

0 commit comments

Comments
 (0)