Header-only RAII wrapper over the C ABI for C++20. Zero cost abstraction — the zinc::SharedRegion class wraps the C handle with move semantics and std::span access.
No build step. Copy include/zinc.hpp into your project, or use the included path.
Requires libzinc_core.dylib / libzinc_core.so at link time.
add_library(zinc INTERFACE)
target_include_directories(zinc INTERFACE ${ZINC_ROOT}/adapters/cpp/include)
target_link_libraries(your_target PRIVATE zinc)Pending package registration. For now, vendor the header.
#include "zinc.hpp"
#include <iostream>
int main() {
// Process A — create
auto region = zinc::SharedRegion::create("/my-data", 4096);
auto bytes = region.bytes();
*reinterpret_cast<float*>(bytes.data()) = 42.0f;
region.notify();
// Process B — open
auto region2 = zinc::SharedRegion::open("/my-data");
region2.wait(5000);
auto bytes2 = region2.bytes();
float val = *reinterpret_cast<const float*>(bytes2.data());
std::cout << val << "\n"; // 42.0
}Create a new shared region. Throws std::system_error on failure.
Open an existing shared region.
Zero-copy span of the shared memory.
Size of the region.
Signal all waiters.
Block until notified.
Release the handle (also in destructor).
The header is published as part of the Zinc core release on GitHub.
gh release upload v0.1.0 adapters/cpp/include/zinc.hpp| OS | Status |
|---|---|
| Linux | ✅ |
| macOS | ✅ |
Windows is not supported. Zinc requires POSIX
shm_open+mmap.