# 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:** 5

<div class="post-metadata">

**Author:** ![jrose](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jrose/32/408_2.png) [@jrose](https://forums.swift.org/u/jrose)\
**Post date:** [September 27, 2020, 12:36am UTC](https://forums.swift.org/t/formalizing-cdecl/40677/5 "2020-09-27T00:36:09Z")

</div>

Okay, why `@objc @cdecl` together? When thinking this through, I considered several options:

- `@cdecl` and `@objc` are both valid on top-level functions, but behave differently: `@objc` allows using ObjC-only types and `@cdecl` does not.

- `@cdecl` and `@objc` are interchangeable on Apple platforms, i.e. you can use ObjC-only types in `@cdecl` functions.

- `@cdecl` allows using ObjC-only types on Apple platforms and you can't write `@objc` on a top-level function at all

- `@cdecl` does not allow ObjC-only types, and you can't write `@objc` on a top-level function at all

- `@cdecl` does not allow ObjC-only types, but `@objc @cdecl` does

I also thought about increasing interop capabilities so that anything that Swift can expose to Objective-C can be exposed to C as well with some sort of opaque struct pointer type—then there are no more types requiring ObjC interop! Sadly, I came to the conclusion that it was just a dream, because you'd still expose them _differently_ on platforms with/without ObjC interop, and it's unclear whether you'd even be able to tell what to expose from Swift when there's no such thing as "ObjC ancestry". (And you can't expose _everything_ because Swift allows naming conflicts that C does not, thanks to modules and nesting. Additionally, exposing more things than `@objc` does today would change the behavior of the "infer-`@objc`-for-me" annotation `@objcMembers`, which makes it a source-breaking change.)

---

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