[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lua and C++
- From: v <v19930312@...>
- Date: Mon, 30 Mar 2020 11:26:40 +0300
On Mon, 2020-03-30 at 00:08 -0400, Jonathan Goble wrote:
> General question to inform some possible personal endeavors over the
> summer: I know that stock Lua will compile cleanly as C++ as well as
> C. Can a Lua executable compiled as one (C or C++) successfully load
> and use an extension module (*.dll or *.so) written in the other? If
> so, are any special steps needed, and what caveats are there (and are
> there any open-source examples I can look at)? If not, is the problem
> something that might be easily overcome with some tinkering, or is
> the problem more intractable? I suspect they can load each other
> without issues, but I'm not certain.
> I'm most interested in a C-compiled Lua and C++ extension module, but
> the other direction (C++ Lua and C module) is of interest also. I
> have only worked in the past with C for both, partially due to my
> lack of C++ exposure until this semester of college, so I have never
> attempted C++ Lua compilation or module code.
There is a bunch of C++ modules in luarocks that work just fine with
standard Lua that was built as C. Only limitation is that such C++
module should not expect Lua errors to unwind stack. Other way around
(C extension, C++ Lua) problems should be completely gone.
Only thing that worries me is mangling of function names that is likely
to prevent module correctly linking with Lua built in mismatching mode.
You'd better just try this and see (e.g. build standard lua interpreter
in C++ mode and try loading some C module).