[swift-users] C compatible structs
Chris Lattner
clattner at apple.com
Tue Aug 2 23:32:47 CDT 2016
> On Aug 1, 2016, at 9:12 AM, Dmitri Gribenko via swift-users <swift-users at swift.org> wrote:
>
> On Mon, Aug 1, 2016 at 4:20 AM, KS Sreeram via swift-users
> <swift-users at swift.org> wrote:
>> Hello
>>
>> Is it possible to declare Swift structs that have C compatible memory
>> layout?
>
> The only supported way to do this is to declare your structs in a C
> header that you import in Swift as a module, and #include in your C
> libraries.
Right. In the future we will probably add the ability to put explicit alignment/layout information on structure fields. This would be useful for this, as well as other cases where you’re trying to match a specific layout used in an on-disk file format or memory mapped device. That said, this doesn’t fit in the scope for Swift 4 stage 1.
-Chris
More information about the swift-users
mailing list