So this: if let data = someArrayGeneratingFunction() { cFunction(UnsafeMutablePointer(data)) }
Has issues with the array passed to c getting corrupted, but this doesn't: let data = someArrayGeneratingFunction() if let data = data { cFunction(UnsafeMutablePointer(data)) } *___________________________________* *James⎥Head of Trolls* *ja...@supmenow.com <ja...@supmenow.com>⎥supmenow.com <http://supmenow.com>* *Sup* *Runway East * *10 Finsbury Square* *London* * EC2A 1AF * On 28 July 2016 at 21:32, Dmitri Gribenko <griboz...@gmail.com> wrote: > On Thu, Jul 28, 2016 at 1:27 PM, James Campbell via swift-users > <swift-users@swift.org> wrote: > > How are arrays passed to C in Linux ? I tried unwrapping an optional > array > > in an if statment and passing it to c. it seemed like the array was > > deallocated however if I stored it in a local var in the function before > the > > if statment it worked perfectly fine, sureley this shouldn't work either > ? > > Would you mind pasting the code example? > > Dmitri > > -- > main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if > (j){printf("%d\n",i);}}} /*Dmitri Gribenko <griboz...@gmail.com>*/ >
_______________________________________________ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinfo/swift-users