3 ms·
Is there a difference between @extern and @native? I could have imagined that it would have been more compatible if Scala-JVM and Scala-Native used the same an
by airless_bar 10y ago
Is there a difference between @extern and @native?
I could have imagined that it would have been more compatible if Scala-JVM and Scala-Native used the same annotations (using JNI behind the scenes on the JVM).
- sjrd 10y agoI would explain the difference as: @native says please implement this Scala method of this Scala class in C, respecting all the JVM calling conventions and memory model. @extern says call this C function that never knew about Scala or the JVM, respecting all the C calling conventions and memory model.
- densh 10y ago@native implies JNI-style definition to be available along the Scala method definition. @extern lets you call straight to C code without any additional ceremony, all you need is a single forward declaration.