C/FFI interop


(David Turnbull) #1

Option 1. Export your Swift to Obj-C. Write Obj-C that exports C. Compile
to a library.

Option 2. Use this syntax and swift-demangle to figure out the symbols:

public var badfood:@convention(c)(Int) -> Void = { (i:Int) in

    print(i)

}

-david

···

On 12/23/15, Thomas Catterall via swift-users <swift-users@swift.org> wrote:

> Indeed I was - I'm quite sorry for the confusion, I didn't make my intent
> clear as I should have, such as through example. What I'm referring to
is,
> for instance, offering a way for a Ruby library to interface with a
module
> written in Swift to communicate with Redis (as an example, not something
I'm
> thinking too seriously about).


(Brent Royal-Gordon) #2

Option 2. Use this syntax and swift-demangle to figure out the symbols:

public var badfood:@convention(c)(Int) -> Void = { (i:Int) in
    print(i)
}

There's an @asmname("foo") directive which can override name mangling, but I don't know how useful it is in practice for this kind of thing.

···

--
Brent Royal-Gordon
Architechies