You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ZeptoLibC is not intended to implement the full C library and does the bare minimum to support I/O operations (just printf()). The aim is to allow simple porting of existing C code to freestanding/baremetal environments such as WASM and embedded systems.
All ZeptoLibC functions start with the prefix zepto_, eg. zepto_malloc() so as to not clash with any existing C functions. The file zeptolibc.h provides #defines for mapping malloc() -> zepto_malloc().
zeptolibc.init() may be passed null for both write function and allocator. A null allocator will cause malloc() to always return NULL. A null write function will silently drop written data.
conststd=@import("std");
constzeptolibc=@import("zeptolibc");
constc=@cImport({
@cInclude("greeting.c");
});
fnwriteFn(data:[]constu8) void {
_=std.io.getStdOut().writer().write(data) catch0;
}
pubfnmain() !void {
vargpa=std.heap.GeneralPurposeAllocator(.{}){};
constallocator=gpa.allocator();
// init zepto with a memory allocator and a write function (used for stdout and stderr)zeptolibc.init(allocator, writeFn);
c.my_greeting();
}
About
Some basic libc functions for working with C code in Zig