Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2479269

Browse files
committed
SE-0495: Add details on enums in the compatibility header
1 parentc886c76 commit2479269

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

‎proposals/0495-cdecl.md‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,17 @@ A `@c` enum may declare a custom C name, and must declare an integer raw type co
6565
```swift
6666
@c
6767
enumCEnum:CInt{
68-
casea
69-
caseb
68+
casefirst
69+
casesecond
7070
}
7171
```
7272

7373
The attribute`@objc` is already accepted on enums. These enums qualify as an Objective-C representable type and are usable from`@objc` global function signatures but not from`@c` functions.
7474

75+
In the compatibility header, the`@c` enum is printed with the C name specified in the`@c` attribute or the Swift name by default. It defines a storage of the specified raw type with support for different dialects of C.
76+
77+
Each case is printed using a name composed of the enum name with the case name attached. The first letter of the case name is capitalized automatically. For the enum above, the generated cases for C are named`CEnumFirst` and`CEnumSecond`.
78+
7579
###`@c @implementation` global functions
7680

7781
Extend support for the`@implementation` attribute, introduced in[SE-0436](https://github.com/swiftlang/swift-evolution/blob/main/proposals/0436-objc-implementation.md), to global functions marked with either`@c` or`@objc`. These functions are declared in an imported C or Objective-C header, while the Swift function provides their implementation. Type-checking ensures the declaration matches the implementation signature in Swift. Functions marked`@implementation` are not printed in the compatibility header.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp