Files
kingchenc 6433c9b3de bindings/r: build the C ABI from source for the WebAssembly target (#244)
## Problem
r-universe builds every package to WebAssembly (webR) in addition to the native platforms, calling `./configure --host=wasm32-unknown-emscripten`. `bindings/r/configure` only knew Linux/macOS/Windows and exited with `unsupported OS 'Emscripten'`, so the **WASM job was the single red check** on an otherwise fully-published r-universe build (all native platforms + deploy are green; the package installs fine everywhere).

## Fix
The r-universe wasm build image ships **cargo** (`/usr/local/cargo/bin`) and **emscripten** (`EMSDK` on PATH). So instead of needing a prebuilt wasm lib (which would risk an emscripten ABI/version mismatch), `configure` now detects the Emscripten host and **builds the C ABI staticlib from source** for `wasm32-unknown-emscripten` in-place — compiled with the image's own emscripten, so the ABI always matches. The static `libwickra.a` is linked into the package object (no shared lib, no rpath).

`wickra-core`'s rayon batch needs threads (absent on wasm), so the wasm build drops it via `--no-default-features`. `wickra-c` now takes `wickra-core` as a direct path dep with `default-features = false` plus a default `parallel` feature that re-enables it for native builds (a member-level `default-features = false` is ignored when inheriting a workspace dep — that was the trap). 

## Validated locally
- `cargo build -p wickra-c` (default) → rayon present, builds.
- `cargo build -p wickra-c --no-default-features` (the wasm feature path) → rayon **gone**, builds.
- `cargo build --workspace`, clippy, fmt all clean; `configure` passes `sh -n`.

## Cannot be validated locally
No Rust/emscripten wasm toolchain here. The wasm build only runs in r-universe, and `configure` downloads the matching `v${version}` source tag — so this takes effect from the **first release that includes it** (the tagged source must contain the feature toggle). Open risks: whether the image has the `wasm32-unknown-emscripten` Rust target pre-installed (configure runs `rustup target add` best-effort) and the wasm build time. Worth one r-universe rebuild to confirm.

Not merging — review first.
2026-06-10 01:44:48 +02:00
..

Wickra — C / C++

CI codecov GitHub release License: MIT OR Apache-2.0

Streaming-first technical indicators for C and C++. A prebuilt shared/static library plus a generated wickra.h — no system dependencies.

Wickra is a multi-language technical-analysis library with a Rust core and bindings for Python, Node.js and WebAssembly, plus a C ABI for C/C++, C#, Go, Java, R and any other C-capable language. Every indicator is an O(1) streaming state machine, so live trading bots and historical backtests share the exact same implementation. This package is the C ABI hub: it compiles the core to a C-compatible shared/static library plus a generated header, so any C-capable language (C, C++, Go, C#, Java, R) links against one artifact instead of re-wrapping every indicator natively.

Install

Grab the prebuilt header + library for your platform from the GitHub releases — each archive has wickra.h, the optional wickra.hpp C++ wrapper, and the shared/static library — or build from source:

cargo build -p wickra-c --release
# -> target/release/libwickra.{so,dylib} or wickra.dll (+ import lib) + a staticlib

Then compile against the header and link the library (cc app.c -I include -L lib -lwickra -lm -o app).

Quick start

#include "wickra.h"

struct Rsi *rsi = wickra_rsi_new(14);              /* NULL on invalid params */
for (size_t i = 0; i < n; ++i) {
    double v = wickra_rsi_update(rsi, prices[i]);  /* NaN during warmup       */
    if (v == v && v > 70.0)                        /* v == v is the NaN check */
        printf("overbought\n");
}
wickra_rsi_free(rsi);                              /* exactly once per _new   */

Every indicator is an opaque handle with the same five functions — _new / _update / _batch / _reset / _free. update is O(1); there is no RAII across the C boundary, so each _new needs exactly one _free, and every function is NULL-safe (a NULL handle yields NaN or a no-op, never a crash). Multi-output indicators (MACD, Bollinger, ADX, …) take a pointer to a #[repr(C)] struct and return a bool. The optional wickra.hpp wraps any handle in a move-only wickra::Handle for exception-safe C++ lifetimes.

Documentation

The full indicator catalogue, guides, quickstarts, and API reference live in the main repository and documentation site:

Wickra ships native bindings for Python, Node.js, WebAssembly and Rust, plus this C ABI hub that any C-capable language (C, C++, Go, C#, Java, R) links against — all exposing the same indicators from the shared Rust core.

Disclaimer

Wickra is an indicator toolkit, not a trading system. The values it computes are deterministic transforms of the input data — they are not financial advice and do not predict the market. Any use in a live trading context is at your own risk. The library is provided as is, without warranty of any kind.

License

Licensed under either of Apache-2.0 or MIT at your option.