Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

A nice, I might give that a try, though the

    @_silgen_name("foobar") func foobar()
does seem to work just fine for now. Could change in the future of course, though I wonder how likely it is that the calling convention for this kind of Swift function is actually going to change.

Note that the whole purpose of the function is to enter the Swift side from C just once. After that all is good, you can register any kind of convention-C callbacks.

What I'd like to see is the ability to specify `@convention(c)` not just on types, but also on functions and structs. That would be sweet and reduce the requirement for C wrappers even more.



I was either told or read (during the 2.x time frame) they were likely going to break @_silgen_name. @_cdecl was added to replace this (at least for my usage case), but I think it is still unfinished and not official, hence the leading underscore.

It happens that @_silgen_name didn't break for me in 3.0. But I've been moving to @_cdecl.


I switched to `@_cdecl` and everything still seems to work. Seems to be the much better option, thanks for the hint!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: