Hello, wired
A wired program has no libc: no main, no printf. wired.h gives you the
replacement for both, and this page shows the smallest program that uses them.
Code
#define WIRED_MAIN /* this file provides _start, memcpy and memset */#include "wired.h"
int wired_main(int argc, char** argv) { (void)argc; (void)argv; wired_log_str("hello\n"); /* stderr */ return 0;}Output
$ ./hellohelloHow it works
Section titled “How it works”#define WIRED_MAINbefore#include "wired.h"emits the_startentry point and thememcpy/memseta-nostdlibbinary needs. Define it in exactly one file._startcalls yourwired_main(argc, argv); its return value becomes the exit status.wired_log_strwrites a NUL-terminated string to stderr.
Build and run
Section titled “Build and run”Build the SDK archive once, then compile your file freestanding against it:
just libclang -target x86_64-linux-gnu -ffreestanding -fno-stack-protector \ -fno-builtin -nostdlib -static \ -Isrc -o hello main.c build/libwired.a./helloEvery other page in this guide builds the same way.