Welcome to ZigLaunch.org

  • Welcome to Zig Launch. Here you’ll find a collection of introductory files to help get you jump started into using the Zig programming language.
  • Zig is a simple but very powerful language. Soon, you’ll be on your way to making anything from your next little utility, website, compiling and using C code, to even making an operating system.
  • Further Reading

  • Click here for the language reference.
  • Click here for the standard library documentation.
  • Click here for ziglearn.org, a more general introduction to the language.
  • Contributing

  • Want to request or add your own examples to the site? We’re on Github!
  • https://github.com/nektro/ziglaunch

Cross Compiled Freestanding Library For Cortex M4

This example demonstrates how to set up a freestanding static library for a cross-compiled target, which can be used to incrementally replace C functions with Zig functions. In this case we’ll be compiling for an nRF52 Development Kit, containing a Cortex-M4 processor with FPU. We use the freestanding OS tag since we are not using libc on our device. See the Zig docs for a full list of supported targets...

November 27, 2020

Static Library

Here, the export keyword is used to signify that the add function will be available post-compilation in a C ABI compatible way. Additionally, we see test blocks being used to ensure that our function behaves correctly. These blocks are ran when using zig test. src/main.zig const std = @import("std"); const testing = std.testing; export fn add(a: i32, b: i32) i32 { return a + b; } test "basic add functionality" { testing....

November 22, 2020

Hello World!

The classic “Hello World!” program. src/main.zig const std = @import("std"); pub fn main() anyerror!void { std.log.info("Hello World, from Zig!", .{}); } build.zig const std = @import("std"); const Builder = std.build.Builder; pub fn build(b: *Builder) void { const target = b.standardTargetOptions(.{}); const mode = b.standardReleaseOptions(); const exe = b.addExecutable("ziglaunch", "src/main.zig"); exe.setTarget(target); exe.setBuildMode(mode); exe.install(); const run_cmd = exe.run(); run_cmd.step.dependOn(b.getInstallStep()); if (b.args) |args| { run_cmd.addArgs(args); } const run_step = b.step("run", "Run the app"); run_step....

November 22, 2020