tannergooding
tannergooding
CC#
Created by voltagex on 6/24/2024 in #help
LibraryImport examples, especially on Linux
It’s often used for high performance scenarios like graphics bindings for games, rather than one off helpers for lob apps or tools
85 replies
CC#
Created by voltagex on 6/24/2024 in #help
LibraryImport examples, especially on Linux
ClangSharp tends to be used to bind against entire libraries or sdks, providing everything and as close to “#include <header.h>” as you can get in dotnet
85 replies
CC#
Created by voltagex on 6/24/2024 in #help
LibraryImport examples, especially on Linux
LibraryImport works great when you need a small number of C# friendly bindings that take advantage of marshaling
85 replies
CC#
Created by voltagex on 6/24/2024 in #help
LibraryImport examples, especially on Linux
No, ClangSharp and LibraryImport are basically parallel tools. They do similar things, but with overall different intents/approaches
85 replies
CC#
Created by voltagex on 6/24/2024 in #help
LibraryImport examples, especially on Linux
It’s not necessarily the easiest tool to use, as it is essentially a wrapper over clang and therefore requires many options to be passed in, much as actual clang does But it’s used by a large number of projects, including at Microsoft, to maintain bindings for various languages
85 replies
CC#
Created by voltagex on 6/24/2024 in #help
LibraryImport examples, especially on Linux
People often use tooling to make it simpler, things like ClangSharp will take a c header and produce blittable bindings directly
85 replies
CC#
Created by voltagex on 6/24/2024 in #help
LibraryImport examples, especially on Linux
Meaning a signature that is as close to what native defines as possible, generally these are fully blittable (require no marshaling), use pointers, etc
85 replies
CC#
Created by voltagex on 6/24/2024 in #help
LibraryImport examples, especially on Linux
It really depends on the needs and goals of your application/library and how you want to maintain your code long term
85 replies
CC#
Created by voltagex on 6/24/2024 in #help
LibraryImport examples, especially on Linux
Writing 1-1 bindings against native can be beneficial though. While it requires the caller to be more verbose, it can help improve performance and the overall readability/maintainability of the code, as you can more precisely see what’s actually happening That’s not required in many scenarios though, which is why the safe wrappers the generator creates can often be good as well
85 replies