# C++ interoperability question

**URL:** <https://forums.swift.org/t/c-interoperability-question/65063>\
**Category:** Compiler\
**Created:** [May 18, 2023, 10:19pm UTC](https://forums.swift.org/t/c-interoperability-question/65063 "2023-05-18T22:19:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mobility](https://avatars.discourse-cdn.com/v4/letter/m/f4b2a3/32.png) [@Mobility](https://forums.swift.org/u/Mobility)\
**Post date:** [May 18, 2023, 10:19pm UTC](https://forums.swift.org/t/c-interoperability-question/65063/1 "2023-05-18T22:19:46Z")

</div>

Does the new C++ interoperability allow the main() function to reside in the C++ code, or is it meant only to assist with making it easier to add C++ code to an existing Swift program?

---

<div class="post-metadata">

**Author:** ![tongjiew](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/tongjiew/32/28772_2.png) [@tongjiew](https://forums.swift.org/u/tongjiew)\
**Post date:** [May 19, 2023, 12:48am UTC](https://forums.swift.org/t/c-interoperability-question/65063/2 "2023-05-19T00:48:30Z")

</div>

I believe the answer is yes, and I think the C++ interop project is a bidirectional interop project.

---

<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:** [May 19, 2023, 2:31am UTC](https://forums.swift.org/t/c-interoperability-question/65063/3 "2023-05-19T02:31:02Z")

</div>

Yes, it's totally possible to have a program whose main entry point is in C++ but that invokes Swift APIs from it. We will be posting a sample CMake project in the near future that showcases this kind of setup , so stay tuned for that :)

---

<div class="post-metadata">

**Author:** ![Mobility](https://avatars.discourse-cdn.com/v4/letter/m/f4b2a3/32.png) [@Mobility](https://forums.swift.org/u/Mobility)\
**Post date:** [May 19, 2023, 3:29pm UTC](https://forums.swift.org/t/c-interoperability-question/65063/4 "2023-05-19T15:29:59Z")

</div>

I also wonder if there is any C++ code that might be problematic, for instance what uses threads, or lots of templates or even complicated preprocessor macros.
