Skip to content

Conversation

xymus
Copy link
Contributor

@xymus xymus commented Apr 28, 2025

Pitch to formalize @c to identify global functions as callable from C code, and supporting features.

@xymus xymus marked this pull request as draft April 28, 2025 19:37

> Note: This proposal aims to formalize, clean up and extend the long experimental `@_cdecl`. While experimental this attribute has been widely in use so we will refer to it as needed for clarity in this document.

## Motivation

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wasn't super clear to me, I think that you should lead with the fact that there are two ways Swift can support interop:

  • by having the compiler emit a header file that contains C declarations for Swift symbols
  • by implementing functions that are declared in a user-written header

and that @cdecl/@objc are for the former and @implementation for the latter.

Copy link
Contributor Author

@xymus xymus Aug 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, I changed the paragraph structure to hopefully make the alternatives clearer.

@xymus xymus marked this pull request as ready for review August 21, 2025 22:49
@coofzilla
Copy link

Any timeline on this? Having @cdecl officially supported would make Swift~C/Python interop much safer and easier in my project!

@rjmccall rjmccall added the LSG Contains topics under the domain of the Language Steering Group label Sep 8, 2025
@xymus xymus changed the title [Pitch] Formalize @cdecl [Pitch] C compatible functions and enums with @c Sep 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LSG Contains topics under the domain of the Language Steering Group
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants