capnp-fortran

Native modern-Fortran Cap’n Proto: wire runtime, packed and canonical codecs, capnpc-fortran schema plugin, optional C ABI, and two-party RPC. No C library underneath.

F2018 wire format capnpc plugin RPC L1 fpm

New here?

Goal

Go to

Install fpm / pixi and build the suite

Install

Write and read a message from a .capnp schema

Tutorial

Generate modules with capnpc-fortran

Code generation

Call a capability over a socket

Tutorial (RPC section) + RPC

Byte-compatible with c-capnproto / C++

Interop

Full procedure list

API reference

Install (shortest path)

With fpm and a recent gfortran:

$ git clone https://github.com/HaoZeke/capnp-fortran.git
$ cd capnp-fortran
$ fpm build && fpm test

Pinned toolchain (gfortran, fpm, fypp, capnp):

$ pixi install
$ pixi run build && pixi run test

The plugin binary lands under build/gfortran_*/app/capnpc-fortran. Details, codegen, and interop builds: Install.

What you get

  • Wire runtime: struct / list / far / double-far / capability pointers, growable arena, default-XOR scalars, Text/Data, traversal and depth guards

  • Serialization: stream framing, packed (whole-buffer + incremental), file helpers, zero-copy views, orphans, deep copy

  • Canonical form: byte-parity with capnp convert binary:canonical

  • Codegen: capnpc-fortran as a capnp compile -o plugin — structs, unions, groups, enums, constants, imports, branded generics, typed interface stubs

  • C ABI: capnp_cabi + cmocka golden master vs c-capnproto

  • RPC: two-party level 1 vat (bootstrap, calls, pipelining, embargo), level 2 persistence hooks, optional live C++ peer test

Parity table and honesty about L3/L4 (unimplemented, same as C++): see the project README.

Documentation map

Install

fpm, pixi, building the plugin, and optional interop deps.

Install
Tutorial

First message round-trip, then a typed Adder RPC client and server.

Tutorial
Code generation

capnp compile -o capnpc-fortran and the shape of generated modules.

Code generation
Architecture

Module layers, wire mapping, arena, emitter, and the RPC vat.

Library architecture
Interop

c-capnproto golden master and the capnp-C++ EzRpc peer.

Interop
RPC

Two-party level 1: tables, pipeline, streams, persistence hooks.

RPC
API reference

Public procedures for messages, fields, pack, canonical, C ABI, RPC.

API reference