# Formalizing @cdecl

**URL:** <https://forums.swift.org/t/formalizing-cdecl/40677>\
**Category:** Pitches\
**Created:** [September 27, 2020, 12:15am UTC](https://forums.swift.org/t/formalizing-cdecl/40677 "2020-09-27T00:15:13Z")\
**Posts on this page:** 1\
**Showing post:** 50

<div class="post-metadata">

**Author:** ![Alex\_L](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/alex_l/32/6202_2.png) [@Alex\_L](https://forums.swift.org/u/Alex_L)\
**Post date:** [March 11, 2022, 7:51pm UTC](https://forums.swift.org/t/formalizing-cdecl/40677/50 "2022-03-11T19:51:04Z")

</div>

I am interested in working on pitching an attribute like `@expose` that was proposed in this thread. We would like to adopt it for Swift and C++ interop, to control which Swift APIs get exposed to C++ (APIs would have to be explicitly annotated with `@expose`). I think it could potentially act as a replacement for `@_cdecl` as well.

So far I have thought about the following behavior for this attribute:

- `@expose` - tells the compiler that this declaration is exposed to a foreign language interface (C/C++/Objective-C++, in one unified header). Most likely when applied to something like a struct, it will expose all its public members too. Note that in this case the Swift declaration will still use the underlying Swift ABI.

- `@expose(c++, name)` - tells the compiler that this declaration is exposed to a foreign language interface. In the generated C++ interface, this declaration will be renamed with the specified name.

- `@expose(c, name, convention: cdecl)` - equivalent to today's `@_cdecl(name)` essentially.

I am most likely going to work on a formal evolution pitch and proposal for `@expose` sometime this year, but I'm interested in getting feedback before then as well.

---

_[View the full topic](https://forums.swift.org/t/formalizing-cdecl/40677)._
