From 2479269b919a730eae9009a0090bc87d9e45ce1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexis=20Laferri=C3=A8re?= Date: Fri, 17 Oct 2025 11:22:51 -0700 Subject: [PATCH 1/3] SE-0495: Add details on enums in the compatibility header --- proposals/0495-cdecl.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/proposals/0495-cdecl.md b/proposals/0495-cdecl.md index 727e910214..245353098c 100644 --- a/proposals/0495-cdecl.md +++ b/proposals/0495-cdecl.md @@ -65,13 +65,17 @@ A `@c` enum may declare a custom C name, and must declare an integer raw type co ```swift @c enum CEnum: CInt { - case a - case b + case first + case second } ``` 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. +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. + +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`. + ### `@c @implementation` global functions 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. From 0e14aa54f5de5f428ce3f309d01fd2560cd7018b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexis=20Laferri=C3=A8re?= Date: Fri, 17 Oct 2025 11:35:44 -0700 Subject: [PATCH 2/3] SE-0495: Clarify the symbols emitted and ABI compatibility --- proposals/0495-cdecl.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/proposals/0495-cdecl.md b/proposals/0495-cdecl.md index 245353098c..cfbc2d81d8 100644 --- a/proposals/0495-cdecl.md +++ b/proposals/0495-cdecl.md @@ -169,7 +169,9 @@ Existing adopters of `@_cdecl` can replace the attribute with `@objc` to preserv ## ABI compatibility -Marking a global function with `@c` or `@objc` makes it use the C calling convention. Adding or removing these attributes on a function is an ABI breaking change. Updating existing `@_cdecl` to `@objc` or `@c` is ABI stable. +The compiler emits a single symbol for `@c` and `@objc` functions, the symbol uses the C calling convention. + +Adding or removing the attributes `@c` and `@objc` on a function is an ABI breaking change. Changing between `@c` and `@objc` is ABI stable. Changing between `@_cdecl` and either `@c` or `@objc` is an ABI breaking change since `@_cdecl` emits two symbols and Swift clients of `@_cdecl` call the one with the Swift calling convention. Adding or removing the `@c` attribute on an enum is ABI stable, but changing its raw type is not. From 626a4afebcc8e764abc3f1f5265de98371d480cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexis=20Laferri=C3=A8re?= Date: Thu, 13 Nov 2025 14:10:18 -0800 Subject: [PATCH 3/3] SE-0495: Mark @c as implemented on 6.3 --- proposals/0495-cdecl.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proposals/0495-cdecl.md b/proposals/0495-cdecl.md index cfbc2d81d8..74ce05a411 100644 --- a/proposals/0495-cdecl.md +++ b/proposals/0495-cdecl.md @@ -4,7 +4,7 @@ * Author: [Alexis Laferrière](https://github.com/xymus) * Review Manager: [Steve Canon](https://github.com/stephentyrone) * Status: **Active Review (September 25th...October 9th, 2025)** -* Implementation: On `main` with the experimental feature flags `CDecl` for `@c`, and `CImplementation` for `@c @implementation`. With the exception of the `@objc` support for global functions which is available under the name `@_cdecl`. +* Implementation: On `6.3`. With the exception of the `@objc` support for global functions which is not yet implemented. * Review: ([pitch](https://forums.swift.org/t/pitch-formalize-cdecl/79557))([review](https://forums.swift.org/t/se-0495-c-compatible-functions-and-enums/82365)) ## Introduction