Is it possible to implement interoperability with C++ and Objective-C/C++? #217
-
Is it possible to implement interoperability with C++, Objective-C, and Objective-C++ by using Nelua metaprogramming facilities? If some of the Nelua targets are system programming and making of libraries, interact directly with C++ and Objective-C/C++ would be a very good idea. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Yes, it is possible. But requires you to write a wrapper for Nelua. Here's an example of interoperability with C++ in Nelua. As you can see, there's a wrapper for the Hello library ( It's basically like FFI <-> C++ method, you make a wrapper of it, compile it to shared library, and then use FFI to define and use the functions. Except the difference is, you don't use |
Beta Was this translation helpful? Give feedback.
Yes, it is possible. But requires you to write a wrapper for Nelua. Here's an example of interoperability with C++ in Nelua.
As you can see, there's a wrapper for the Hello library (
hello.cpp
). It contains functions that wraps C++ functions usingextern "C"
. Inhello.nelua
, it contains several definition oflibhello
withoutnodecl
attribute, and a code that'll run a function fromhello.cpp
usinglibhello
.It's basically like FFI <-> C++ method, you make a wrapper of it, compile it to shared library, and then use FFI to define and use the functions. Except the difference is, you don't use
dlopen
to get the functions, since you can define the functions into your.nelua
, and also you're not …