Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to use a lua library compiled as C++ #604

Merged
merged 1 commit into from
Mar 25, 2024

Conversation

LiquidFenrir
Copy link
Contributor

This is for my (admittedly specific) use case, but also an option that might be good to have.
It is rarely the case, as all the system packaged lua libraries I know of are compiled as C, but for an in-project compiled lua it can happen; since it allows for exceptions to work properly through the lua interface.

In the current master, the extern "C" would result in linking errors (undefined references for every single lua function).
Set to OFF by default to keep compatibility.

I'm using RmlUi alongside sol2, which combines nicely, but I prefer having all the safeties enabled - including exceptions. This is the only thing (alongside a dummy FindLua.cmake for some reason, otherwise RmlUi uses the system library) needed to make it work.

Let me know if this is a bad change or if there are naming conventions you'd want fixed.
I also noticed the cmake branch, don't really know where to PR this. But it's not hard to port over, so master it is.

rarely the case, but for an in-project compiled lua can happen, in which case extern "C" would result in linking errors
allows for exceptions to work properly through the lua interface
@mikke89 mikke89 added build Build system and compilation plugin SVG and Lottie plugins Lua Lua binding issues and removed plugin SVG and Lottie plugins labels Mar 25, 2024
@mikke89
Copy link
Owner

mikke89 commented Mar 25, 2024

Ah, I didn't know Lua could be compiled as C++ to give exceptions. I see that this is officially supported and they even mention the conditional use of the "C" wrapper.

First time I'm hearing about the need for this, but since it's officially supported from the Lua side, it makes sense to add it as an option. So thank you for the pull request, and this looks good to me!

I'll have to remember to add this to the cmake branch as well.

@mikke89 mikke89 merged commit 1e0a719 into mikke89:master Mar 25, 2024
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Build system and compilation Lua Lua binding issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants