Skip to content

krauthaufen/ClangSharp

 
 

Repository files navigation

ClangSharp

ClangSharp are strongly-typed safe Clang bindings written in C# for .NET and Mono, tested on Linux and Windows. ClangSharp is self-hosted and ClangSharp auto-generates itself parsing LLVM-C header files.

If you're on Windows, consider using the ClangSharp 3.6 NuGet Package - built from Clang 3.6 Release.

Building ClangSharp

On Linux using Mono:

 $ git clone http://github.com/mjsabby/ClangSharp
 $ cd ClangSharp
 $ chmod +x build.sh
 $ ./build.sh /path/to/libclang.so /path/clang/include

On Windows using Microsoft.NET:

Note: - you need to run from the Visual Studio Command Prompt of the architecture you want to target.

 :> git clone http://github.com/mjsabby/ClangSharp
 :> cd ClangSharp
 :> build.bat c:\path\libclang.dll C:\path\to\llvm\include

Features

  • Auto-generated using Clang C headers files, and supports all functionality exposed by them ~ which means you can build tooling around C/C++
  • Type safe (CXIndex and CXTranslationUnit are different types, despite being pointers internally)
  • Nearly identical to Clang C APIs, e.g. clang_getDiagnosticSpelling in C, vs. clang.getDiagnosticSpelling (notice the . in the C# API)

ClangSharp PInvoke Generator

A great example of ClangSharp's use case is its self-hosting mechanism Clang Sharp PInvoke Generator

About

Clang bindings for .NET and Mono written in C#

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 98.7%
  • Other 1.3%