Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 954
CPlus Avatar asked Jan 18 '26 12:01

CPlus


1 Answers

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.

like image 55
bscothern Avatar answered Jan 20 '26 00:01

bscothern