[swift-evolution] Ability to pack, order and align certain types of Structs (like in C)

Chris Lattner clattner at apple.com
Fri Apr 8 01:01:02 CDT 2016


> On Apr 7, 2016, at 12:28 PM, hitstergtd+swiftevo--- via swift-evolution <swift-evolution at swift.org> wrote:
> 
> To the community:
> 
> Neither am I a compiler/language design expert nor have I previously
> written a proposal to that effect, so I apologise if I have
> trivialised the matter especially with regard to other parts of Swift
> or if some of it already exists. I am also aware that what I've
> proposed herein maybe possible through alternate means. However, the
> aim of this is to make it a first-class feature in Swift itself. For
> those unfamiliar with what is being requested, please see [2], [5] and [8].
> 
> I have also filed this as a language feature request at [7].

Yes, this would be a great thing to have, but it requires significant design and implementation work, so I’m afraid it is out of scope for Swift 3.  In the meantime, a lame workaround is that you can define your struct in C and import it.  Swift will honor the layout of the C type.

-Chris


More information about the swift-evolution mailing list