<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">In general, I find that importing C arrays is problematic. I don't have any nice solution to offer, though.</div><div class=""><br class=""></div><div class="">For now, you might be able to get away with withUnsafePointer(&amp;event.data) { ... }.</div><br class=""><div class="">
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Lucida Grande';  font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; ">Félix</span>
</div>

<br class=""><div><blockquote type="cite" class=""><div class="">Le 22 déc. 2015 à 17:29:10, T.J. Usiyan via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; a écrit :</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">MIDIMetaEvent and MIDIEventUserData are both examples of framework provided types which rely on flexible member arrays. Their last member is (officially) an array of UInt8 with 1 element. In practice, developers are meant to allocate enough space for an array of the necessary length along with the rest of the struct.<div class=""><br class=""></div><div class="">These members come into swift as single element tuples. I propose either automatic import of these as Array or UnsafeReference.</div><div class=""><br class=""></div><div class="">Example of the current situation:</div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class="">/*!</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span class="" style="white-space:pre">        </span>@struct<span class="" style="white-space:pre">                </span>MIDIMetaEvent</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span class="" style="white-space:pre">        </span>@discussion<span class="" style="white-space:pre">        </span>The parameters to specify a MIDI meta event</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class="">*/</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="color:rgb(187,44,162)" class="">public</span> <span style="color:rgb(187,44,162)" class="">struct</span> MIDIMetaEvent {</div><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px" class="">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">public</span> <span style="color:rgb(187,44,162)" class="">var</span> metaEventType: <span style="color:rgb(112,61,170)" class="">UInt8</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">public</span> <span style="color:rgb(187,44,162)" class="">var</span> unused1: <span style="color:rgb(112,61,170)" class="">UInt8</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">public</span> <span style="color:rgb(187,44,162)" class="">var</span> unused2: <span style="color:rgb(112,61,170)" class="">UInt8</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">public</span> <span style="color:rgb(187,44,162)" class="">var</span> unused3: <span style="color:rgb(112,61,170)" class="">UInt8</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">public</span> <span style="color:rgb(187,44,162)" class="">var</span> dataLength: <span style="color:rgb(112,61,170)" class="">UInt32</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">public</span> <span style="color:rgb(187,44,162)" class="">var</span> data: (<span style="color:rgb(112,61,170)" class="">UInt8</span>)</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(187, 44, 162);" class=""><span style="" class="">&nbsp; &nbsp; </span>public<span style="" class=""> </span>init<span style="" class="">()</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">public</span> <span style="color:rgb(187,44,162)" class="">init</span>(metaEventType: <span style="color:rgb(112,61,170)" class="">UInt8</span>, unused1: <span style="color:rgb(112,61,170)" class="">UInt8</span>, unused2: <span style="color:rgb(112,61,170)" class="">UInt8</span>, unused3: <span style="color:rgb(112,61,170)" class="">UInt8</span>, dataLength: <span style="color:rgb(112,61,170)" class="">UInt32</span>, data: (<span style="color:rgb(112,61,170)" class="">UInt8</span>))</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">}</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class="">/*!</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span class="" style="white-space:pre">        </span>@struct<span class="" style="white-space:pre">                </span>MusicEventUserData</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span class="" style="white-space:pre">        </span>@discussion<span class="" style="white-space:pre">        </span>Provides a general struct for specifying a user defined event.&nbsp;</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span class="" style="white-space:pre">        </span>@field<span class="" style="white-space:pre">                </span>length</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span class="" style="white-space:pre">                                        </span>the size in bytes of the data</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span class="" style="white-space:pre">        </span>@field<span class="" style="white-space:pre">                </span>data</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span class="" style="white-space:pre">                                        </span>size bytes of user defined event data</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class="">*/</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="color:rgb(187,44,162)" class="">public</span> <span style="color:rgb(187,44,162)" class="">struct</span> MusicEventUserData {</div><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px" class="">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">public</span> <span style="color:rgb(187,44,162)" class="">var</span> length: <span style="color:rgb(112,61,170)" class="">UInt32</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">public</span> <span style="color:rgb(187,44,162)" class="">var</span> data: (<span style="color:rgb(112,61,170)" class="">UInt8</span>)</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(187, 44, 162);" class=""><span style="" class="">&nbsp; &nbsp; </span>public<span style="" class=""> </span>init<span style="" class="">()</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; <span style="color:rgb(187,44,162)" class="">public</span> <span style="color:rgb(187,44,162)" class="">init</span>(length: <span style="color:rgb(112,61,170)" class="">UInt32</span>, data: (<span style="color:rgb(112,61,170)" class="">UInt8</span>))</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">}</div></div><div class=""><br class=""></div></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=iRI3beHTe3UxYAHTlV3lA38zIPfHMhyuRzgTmGKV6k5gYPbIJnPjEaoKs8qLcjlciUcViqcblBrruch-2FphTCCo6Luiy6yLXRS2aukrDxLwoFdijxe7mM0Ika55M3RNNGUHlSUs-2FnQ-2F9QInP2THUcAm4dgMHCUrYm0U8gfPm5PFhy-2FBmF1fOP-2BiIGysQ-2F-2BiAnmv18UF7PgfbnIBKifGDYAEmSO5JcIRJ-2FsDhTSZdf4G0-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;" class="">
_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></body></html>