Working with C
const c = @cImport({
@cInclude("stdio.h");
});
pub fn main() !void {
_ = c.printf("Hello, world!\n");
}Custom C code
// In file /c-src/greeter.h
void greet(const char *name);
// In file /c-src/greeter.c
#include "greeter.h"
#include <stdio.h>
void greet(const char *name) {
if (name == NULL) {
printf("Hello, world!\n");
} else {
printf("Hello, %s!\n", name);
}
}Last updated