Wait, if variadic calls aren't supported, how is it that NSLog() can be called?
> On Oct 18, 2014, at 18:22 , Roland King <r...@rols.org> wrote: > > >> On 19 Oct 2014, at 9:03 am, Rick Mann <rm...@latencyzero.com> wrote: >> >> >>> On Oct 18, 2014, at 16:40 , Roland King <r...@rols.org> wrote: >>> >>> >>>> On 19 Oct 2014, at 5:23 am, Jean-Daniel Dupas <mail...@xenonium.com> wrote: >>>> >>>> AFAIK, variadic C functions are not (yet) callable from swift code. >>>> >>>> >>> >>> They aren’t - I didn’t remember fnctl() was varidadic. I shall quote an >>> Apple engineer then .. >>> >>> "This is not possible in Swift. C variadics are inherently unsafe, and not >>> compatible with Swift variadics. You're encouraged to provide alternate >>> versions of your collection-y variadics that take an array. Your format-y >>> variadics (like this one?) can use Swift's String's variadic initializers >>> ahead of time." >>> >>> So you get to go wrap fcntl() in something else it seems. >> >> So, how would I do that, exactly? I suppose I have to pass Objective-C >> collection types to a method (which could be a straight C function) from a >> Swift call? That is, can a Swift variadic call translate into a C function >> call that accepts Obj-C collections? > > Write a simple c wrapper around the thing you’re trying to do and that > bridges across to swift. You could probably try to write something really > generic which wraps fcntl() using an UnsafeMutablePtr<UInt8> as a final > argument and then massaging stuff in Swift to poke it over and back, but that > really would be a horror. You’re probably better off just shimming the actual > operations you really actually need into a set of specialized c calls, each > one should take 2-3 lines of code only for that. -- Rick Mann rm...@latencyzero.com _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com