Skip to content

[Pitch] Formalize @cdecl #2813

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

[Pitch] Formalize @cdecl #2813

wants to merge 2 commits into from

Conversation

xymus
Copy link
Contributor

@xymus xymus commented Apr 28, 2025

Pitch to formalize @cdecl 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants