Search code examples
cswiftfunctioninlinebridging-header

Can I bridge C inline functions to Swift?


If I put an inline function in a .h file, then include that in the bridging header, can I invoke it in Swift? (Answer: Yes) But will it still be inline when invoked in Swift?


Solution

  • The compiler will do what it wants but generally the answer is yes. This is part of why the atomics libraries and math shims that go down to C use header only inlined modules. So at least in release builds it can be fully optimized.

    See this for example.