lmcode-c-sample skill

Use lmcode-c-sample as a verified blueprint for embedding lmcode-cpp (dslvm.hpp) in a C11 + C++17 host application with schema discovery, R49 rule entries, dry mode, and LMCODE_RETURN framing.

Purpose

Demonstrate a complete, byte-pinned C11 + C++17 host application that exposes a 45-signature Shop/Ledger domain to DSLB v6 bytecode and passes the shared sample suite.

When to use it

Use lmcode-c-sample when learning how to bind C11 + C++17 domain objects, overloaded methods, operators, R49 rule entries, and LMCODE_RETURN result envelopes with lmcode-cpp (dslvm.hpp).

Install

Clone lmctl-ai/lmcode-c-sample and run ./test.sh with C11 + C++17, Python 3, Node 24, and a DSLB v6 capable lmscript compiler (set LMSCRIPT_BIN to select one).

Commands

git clone https://github.com/lmctl-ai/lmcode-c-sample.git
cd lmcode-c-sample
make test-domain
./test.sh
./build/lmcode-c-sample --version
./build/lmcode-c-sample --lmcode-schema --json
./build/lmcode-c-sample --lmcode-signatures
./build/lmcode-c-sample --lmcode sample-suite/bytecode/001-literals.dslb

Inputs and outputs

Safety rules

Worked examples

prog = _lmcode_ cli="lmcode-c-sample" install="github:lmctl-ai/lmcode-c-sample@latest";
  ledger.record(shop.total());
end _lmcode_
r = run_lmcode(prog);

Errors and exit codes

CodePhaseExitCondition
LOAD_BAD_BYTECODEload3Malformed DSLB v6 header, bad magic or version, truncated section, invalid opcode, or stack depth violation
LOAD_SCHEMA_MISMATCHload332-byte SHA-256 schema hash in DSLB v6 header does not match exact host schema bytes
LOAD_UNBOUNDload3Bytecode imports a context, function, or method signature not registered in the host Registry
RUN_ERRORrun3VM runtime error such as division or remainder by zero
RUN_HOSTrun3Host callback failure, invalid encoding, or expired collection handle
APP_FAILapp4Post-run application domain validation failure or output stream write failure

How to verify

./test.sh