CLanguage 0.22.225

dotnet add package CLanguage --version 0.22.225
                    
NuGet\Install-Package CLanguage -Version 0.22.225
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CLanguage" Version="0.22.225" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CLanguage" Version="0.22.225" />
                    
Directory.Packages.props
<PackageReference Include="CLanguage" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CLanguage --version 0.22.225
                    
#r "nuget: CLanguage, 0.22.225"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package CLanguage@0.22.225
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CLanguage&version=0.22.225
                    
Install as a Cake Addin
#tool nuget:?package=CLanguage&version=0.22.225
                    
Install as a Cake Tool

CLanguage

<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.

Usage

There are two stages:

  1. Compiling using CLanguage.Compiler.CCompiler
  2. Interpreting using CLanguage.Interpreter.CInterpreter

Machine information, such as pointer sizes, is stored in MachineInfo objects.

After compilation, you must create an interpreter, Reset it, then Run it.

Simple Evaluation

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);

Parsing Header Files

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 entries
  • CEnumType.Members — list of CEnumMember (with Name, Value)
  • CFunctionType — has ReturnType and Parameters (each with Name and ParameterType)
  • CompiledVariable — has Name and VariableType

If you need system headers resolved (e.g., #include <stdint.h>), use the CParser directly and provide an include callback.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.
  • net9.0

    • No dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on CLanguage:

Package Downloads
CLanguage.Editor

C parser, compiler, and interpreter.

IoTSharp.Interpreter

Package Description

GitHub repositories (1)

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 44 3/31/2026
0.21.99 2,730 5/7/2025
0.21.98 308 4/30/2025
0.20.74 10,031 2/3/2024
0.19.67 1,676 10/12/2023
0.19.66 2,261 6/8/2023
0.18.54 3,382 1/27/2023
0.18.48 1,956 12/30/2022
0.18.47 4,908 8/26/2022
0.18.46 862 8/26/2022
0.18.45 861 8/26/2022
0.18.43 872 8/22/2022
0.18.42 2,963 6/1/2022
0.17.40 4,234 1/21/2022
0.17.39 816 1/11/2022
0.16.36 1,405 11/17/2021
0.15.30 2,117 8/5/2021
0.14.26 991 3/13/2021
0.13.18 2,324 6/17/2020
Loading failed