You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: proposals/0495-cdecl.md
+6-2Lines changed: 6 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -65,13 +65,17 @@ A `@c` enum may declare a custom C name, and must declare an integer raw type co
65
65
```swift
66
66
@c
67
67
enumCEnum:CInt{
68
-
casea
69
-
caseb
68
+
casefirst
69
+
casesecond
70
70
}
71
71
```
72
72
73
73
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.
74
74
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
+
75
79
###`@c @implementation` global functions
76
80
77
81
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.