CppSharp

将 C/C++ 应用程序接口粘合到高级语言的工具和库。「Tools and libraries to glue C/C++ APIs to high-level languages」

Github stars Tracking Chart

CppSharp is a tool and set of libraries which facilitates the usage of native C/C++ code
with the .NET ecosystem.

It consumes C/C++ header and library files and generates the
necessary glue code to surface the native API as a managed API. Such an API can be
used to consume an existing native library in your managed code or add
managed scripting support to a native codebase.

The supported target languages at present are C# and C++/CLI.

It can also be used as a library to parse native code into a syntax tree with a
rich declaration and type information model.

Releases/Build Status

NuGet Packages Continuous Integration
NuGet GitHub-actions
  1. Libraries
  2. Documentation
  3. Community
  4. Support
  5. Users

Libraries

AST

Mirrors the Clang's C/C++ AST and type system classes in C# APIs.

Check out Clang's AST introduction docs for more details about its architecture.

  • C++ declarations
  • C++ statements / expressions
  • C++ types
  • Class object layout
  • Declaration visitors
  • Type visitors

Parser

Provides APIs for parsing of C/C++ source code into a syntax tree.

  • Parsing of C/C++ source code
  • Parsing of libraries archives symbols
  • Parsing of shared libraries symbols
  • Based on the very accurate Clang C++ parser.

Generator

Generates the glue binding code from a syntax tree of the native code.

  • Multiple backends: C++/CLI and C# (P/Invoke)
  • Multiple ABIs: Itanium, MS, ARM, iOS
  • Multiple platforms: Windows, OS X and Linux
  • Multiple runtimes: .NET and Mono
  • C++ virtual methods overriding from managed code
  • C++ multiple inheritance by translating to C# interfaces
  • C++ std::string
  • C++ default parameter values
  • C/C++ semantic comments (Doxygen) to C# comments
  • Extensible bindings semantics via user passes and type mapping

Documentation

Please see the following resources for more information:

Getting Started

User's Manual

Developer's Manual

Community

Feel free to open up issues on GitHub for any problems you find.

Support

If you need commercial support feel free to open a discussion or issue for discussion.

Users

CppSharp is used by the following projects:

Kythera AI

QtSharp

MonoGame

LLDBSharp

Xamarin

FFMPEG.net

FFmpeg bindings

Tizen bindings

libgd bindings

ChakraSharp

FFmpeg.AutoGen

GLFW3.NET

DearImguiSharp

Please feel free to send us a pull request adding your own projects to the list above.

Main metrics

Overview
Name With Ownermono/CppSharp
Primary LanguageC#
Program languageShell (Language Count: 7)
Platform
License:MIT License
所有者活动
Created At2013-05-10 19:00:56
Pushed At2025-04-18 02:05:24
Last Commit At
Release Count51
Last Release Namev1.1.2 (Posted on )
First Release NameCppSharp (Posted on )
用户参与
Stargazers Count3.2k
Watchers Count152
Fork Count526
Commits Count5.5k
Has Issues Enabled
Issues Count894
Issue Open Count317
Pull Requests Count800
Pull Requests Open Count26
Pull Requests Close Count190
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private