![]() |
VOOZH | about |
dotnet add package CLanguage --version 0.22.225
NuGet\Install-Package CLanguage -Version 0.22.225
<PackageReference Include="CLanguage" Version="0.22.225" />
<PackageVersion Include="CLanguage" Version="0.22.225" />Directory.Packages.props
<PackageReference Include="CLanguage" />Project file
paket add CLanguage --version 0.22.225
#r "nuget: CLanguage, 0.22.225"
#:package CLanguage@0.22.225
#addin nuget:?package=CLanguage&version=0.22.225Install as a Cake Addin
#tool nuget:?package=CLanguage&version=0.22.225Install as a Cake Tool
<img src="https://github.com/praeclarum/CLanguage/raw/master/Documentation/Icon.png" height="20"> 👁 NuGet Package
CLanguage is a .NET Standard library that contains a C/C++ parser, a compiler (to its own VM), and an interpreter (for its VM). It's a very small library that enables you to embed C/C++ scripts into your .NET apps.
It is used to simulate Arduinos in the app iCircuit. It features cycle counting so that infinite loops and long computations can be paused.
I describe other details of it in my blog entry Oops, I Wrote a C++ Compiler.
There are two stages:
CLanguage.Compiler.CCompilerCLanguage.Interpreter.CInterpreterMachine information, such as pointer sizes, is stored in MachineInfo objects.
After compilation, you must create an interpreter, Reset it, then Run it.
There is a static Eval method on CLanguageService to make compiling and executing expressions easier than setting everything up manually.
For example:
var result = CLanguageService.Eval("2 + 3");
Assert.AreEqual(5, result);
You can use CLanguageService.ParseTranslationUnit() to parse C/C++ header files and extract struct/enum definitions, global variables, function declarations, and typedefs without compiling to bytecode.
using CLanguage;
using CLanguage.Syntax;
var code = File.ReadAllText("myheader.h");
TranslationUnit tu = CLanguageService.ParseTranslationUnit(code);
// Struct/class definitions
foreach (var (name, structType) in tu.Structures)
{
Console.WriteLine($"struct {name}:");
foreach (var member in structType.Members)
Console.WriteLine($" {member.Name}: {member.MemberType}");
}
// Enum definitions
foreach (var (name, enumType) in tu.Enums)
{
Console.WriteLine($"enum {name}:");
foreach (var member in enumType.Members)
Console.WriteLine($" {member.Name} = {member.Value}");
}
// Global variables
foreach (var variable in tu.Variables)
Console.WriteLine($"var {variable.Name}: {variable.VariableType}");
// Function declarations
foreach (var func in tu.Functions)
Console.WriteLine($"func {func.Name}: {func.FunctionType}");
// Typedefs
foreach (var (name, type) in tu.Typedefs)
Console.WriteLine($"typedef {name} = {type}");
Key types you can inspect:
CStructType.Members — list of CStructField (with Name, MemberType) and CStructMethod entriesCEnumType.Members — list of CEnumMember (with Name, Value)CFunctionType — has ReturnType and Parameters (each with Name and ParameterType)CompiledVariable — has Name and VariableTypeIf you need system headers resolved (e.g., #include <stdint.h>), use the CParser directly and provide an include callback.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 is compatible. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 2 NuGet packages that depend on CLanguage:
| Package | Downloads |
|---|---|
|
CLanguage.Editor
C parser, compiler, and interpreter. |
|
|
IoTSharp.Interpreter
Package Description |
Showing the top 1 popular GitHub repositories that depend on CLanguage:
| Repository | Stars |
|---|---|
|
IoTSharp/IoTSharp
IoTSharp is an open-source IoT platform for data collection, processing, visualization, and device management.
|
| Version | Downloads | Last Updated |
|---|---|---|
| 0.22.225 | 465 | 3/31/2026 |
| 0.21.99 | 3,100 | 5/7/2025 |
| 0.21.98 | 323 | 4/30/2025 |
| 0.20.74 | 10,111 | 2/3/2024 |
| 0.19.67 | 1,694 | 10/12/2023 |
| 0.19.66 | 2,281 | 6/8/2023 |
| 0.18.54 | 3,399 | 1/27/2023 |
| 0.18.48 | 1,972 | 12/30/2022 |
| 0.18.47 | 4,929 | 8/26/2022 |
| 0.18.46 | 878 | 8/26/2022 |
| 0.18.45 | 876 | 8/26/2022 |
| 0.18.43 | 892 | 8/22/2022 |
| 0.18.42 | 2,976 | 6/1/2022 |
| 0.17.40 | 4,254 | 1/21/2022 |
| 0.17.39 | 832 | 1/11/2022 |
| 0.16.36 | 1,424 | 11/17/2021 |
| 0.15.30 | 2,131 | 8/5/2021 |
| 0.14.26 | 1,007 | 3/13/2021 |
| 0.13.18 | 2,338 | 6/17/2020 |