How is C2CS compared to ClangSharp? #154
-
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hello @iahung3, ClangSharp is provided by Microsoft and is highly used for scenarios where interop with Win32 from C#. I used ClangSharp (the C# API) directly in my earlier various of C2CS, but found it to be troublesome for returning some data in some contexts for purposes of cross-platform bindings. Later versions of C2CS used direct Clang bindings from ClangSharp, but now I use the NuGet package of ClangSharp for downloading Clang native libraries. C2CS is intended for C libraries specifically made for purposes of libraries that are cross-platform. It's made to work on macOS, Linux, and Windows. The intended use case is that abstract syntax tree is parsed for each platform and then merged together looking for inconsistencies between platforms. The merged result is the source of truth for generating bindings. ClangSharp does not provide such functionality, and takes one platform as the source of truth for generating bindings. If you intend to use a C/C++ Windows API and generate bindings for it in C# I recommend using ClangSharp. |
Beta Was this translation helpful? Give feedback.
Hello @iahung3,
ClangSharp is provided by Microsoft and is highly used for scenarios where interop with Win32 from C#. I used ClangSharp (the C# API) directly in my earlier various of C2CS, but found it to be troublesome for returning some data in some contexts for purposes of cross-platform bindings. Later versions of C2CS used direct Clang bindings from ClangSharp, but now I use the NuGet package of ClangSharp for downloading Clang native libraries.
C2CS is intended for C libraries specifically made for purposes of libraries that are cross-platform. It's made to work on macOS, Linux, and Windows. The intended use case is that abstract syntax tree is parsed for each platform and then mer…