Add Linux support #15
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I was trying to investigate YorVeX/ObsCSharpExample#2 and turns out
ObsBase.blogandObsBase.blogvado not work on Linux and it is not possible to make them work in their current form.The current way to use
ObsBase.blogvawith a null pointer is undefined behavior (I did not check the standard, but I am pretty sure we cannot pass a null pointer instead of C struct, the way C structs are passed to functions definitely depends on the ABI), and we are lucky that it worked at all on Windows.The alternative is to use
ObsBase.blogwith an undocumented__arglistkeyword. The issue is that it is not currently implemented in .NET on non-Windows platforms. And while it may be possible to emulate it in C# (although, I am not sure about this), it is ABI-dependent (so, we will have to make a different implementation for each platform) and the way it works on x64 is complicated, to say the least.Unfortunately, the pull request in ClangSharp that added support for variadic arguments does not mention that it is Windows-only and does not produce any warnings about its usages. I did not check if ClangSharp's repo has an open issue for this yet, I will probably do it later and open a new one if I do not find any.
The change I propose in this pull request is to get rid of the automatically generated bindings for these functions and to make a new manual binding for
ObsBase.blogthat does not use variadic arguments and has only one hard-coded argument (which is an ABI-compatible way to call a C function with variadic arguments).I tested the change on both Linux and Windows and I did not find any issues, plugins (I tested the sample plugin in this repository and YorVeX/ObsCSharpExample) now work on Linux and they continue working on Windows.
This is a breaking change!