# How to define structures that can be passed to C?

**URL:** <https://forums.swift.org/t/how-to-define-structures-that-can-be-passed-to-c/23901>\
**Category:** Using Swift\
**Tags:** c-interop\
**Created:** [April 29, 2019, 6:20pm UTC](https://forums.swift.org/t/how-to-define-structures-that-can-be-passed-to-c/23901 "2019-04-29T18:20:48Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![ole](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/ole/32/18720_2.png) [@ole](https://forums.swift.org/u/ole)\
**Post date:** [May 6, 2019, 10:31am UTC](https://forums.swift.org/t/how-to-define-structures-that-can-be-passed-to-c/23901/4 "2019-05-06T10:31:26Z")

</div>

This April 2017 quote from @John_McCall suggests tuples can be used for this purpose:

> [@Guarantees of Tuples as Fixed Sized (stack allocated) Arrays](https://forums.swift.org/t/guarantees-of-tuples-as-fixed-sized-stack-allocated-arrays/5800/3):
>
> Tuples are guaranteed to use a standard C-style layout wherever that layout is ABI-observable, e.g. when you construct an UnsafePointer to one.
> 
> Note that that layout isn't ABI-observable when the tuple is, say, just stored in a struct. The compiler is allowed to break up the tuple and store its components however it likes. Of course, if the compiler does that, and you turn around and construct an UnsafePointer to that property, then the compiler has to reconstitute the tuple into an ABI-compliant temporary that it can give you a pointer to; this is yet another reason why you can't maintain permanent unsafe pointers to components of a struct.

Is this advice this correct?

---

_[View the full topic](https://forums.swift.org/t/how-to-define-structures-that-can-be-passed-to-c/23901)._
