Skip to content

18 · Modules

C / C++ · Clang · C ABI

Prepare C17 and C++17 libraries with Clang. C++ exposes supported concrete classes; native ownership and unsupported pointers or templates require explicit adapters. Prepared code runs without the source compiler.

On this page

Run locally with the matching plugin and runtime. These examples do not run in the browser playground.

C / C++ / Clang · C ABI.

44-extern-cpp.zolo
use plugin native::{cpp}

extern cpp from "./native_fixtures/Person.cpp" use {Person}

extern cpp fn greet(name: str) -> str {
    return "Hello " + name;
}

extern cpp async fn later(value: int) -> int {
    #include <chrono>
    #include <thread>
    std::this_thread::sleep_for(std::chrono::milliseconds(10));
    return value + 1;
}

extern cpp fn call(callback: fn(int) -> int) -> int {
    return callback(40);
}

let person = Person.new(name: "Ana", age: 30)
print(person.greet()) // expected: Hello Ana
print(person.birthday()) // expected: 31
person.age = 32
print(person.age) // expected: 32
print(Person.twice(21)) // expected: 42
print(greet("C++")) // expected: Hello C++
print(await later(41)) // expected: 42
print(call(|value| value + 2)) // expected: 42

Requires the Zolo CLI/host — open in the playground or run locally.

Preparation and deployment

Source-free packaging can retain prepared foreign artifacts, but does not remove runtime or platform dependencies. VM, native and LLVM hosting are covered; foreign bindings reject unsupported WebAssembly targets. The recent provider acceptance covers Windows x64. Python acceptance specifically covers CPython 3.12; other platforms need their own verification.

Reference overview

Global index

Find your way through Zolo

Try an idea

Start here

9 results

9 results

enespt-br