[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Using Lua when built as C++
- From: Matthias Kluwe <mkluwe@...>
- Date: Thu, 30 Jan 2020 16:03:35 +0100
Hi!
Am Do., 30. Jan. 2020 um 15:25 Uhr schrieb Gisle Vanem <gvanem@yahoo.no>:
>
> I did an experiment to build Lua 5.3 as C++.
> It worked fine, but calling any 'lua_x()' causes
> link errors.
>
> The comment in ldo.c indicates it's possible:
> ** LUAI_THROW/LUAI_TRY define how Lua does exception handling. By
> ** default, Lua handles errors with exceptions when compiling as
> ** C++ code, ...
>
> Since LUA_API is either empty or defined as
> '__declspec(dllimport)', I patched luaconf.h to suite
> a C++ ABI:
>
> [...]
As you're looking into `__declspec(dllimport)`, you're probably using
windows. If you're using Visual Studio: The compiler guesses the
source type by the extension. I've been successfull using the compiler
flag /Tp (see https://docs.microsoft.com/en-us/cpp/build/reference/tc-tp-tc-tp-specify-source-file-type?view=vs-2019)
when building Lua as a C++ project.
Regards,
Matthias