Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/donsez/zig-examples
Ziglang examples
https://github.com/donsez/zig-examples
zig
Last synced: 29 days ago
JSON representation
Ziglang examples
- Host: GitHub
- URL: https://github.com/donsez/zig-examples
- Owner: donsez
- Created: 2021-08-05T08:50:56.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-11-22T19:51:14.000Z (about 3 years ago)
- Last Synced: 2024-11-06T06:46:32.763Z (3 months ago)
- Topics: zig
- Language: Zig
- Homepage:
- Size: 4.88 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Zig :: Examples
Zig is a general-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.
https://ziglang.org/
https://ziglang.org/documentation/master/#Introduction
## Installation
### Tarball
```bash
cd ~/devtools
wget https://ziglang.org/builds/zig-macos-x86_64-0.9.0-dev.729+bd8baefaa.tar.xz
xz -d zig-macos-x86_64-0.9.0-dev.729+bd8baefaa.tar.xz
PATH=$PATH:~/devtools/zig-macos-x86_64-0.9.0-dev.729+bd8baefaa
zig env
```
### Brew```bash
brew install zig
```From Git HEAD
```bash
brew install zig --HEAD
```## Examples
### Hello World !
```bash
cd hello
zig build-exe hello.zig
wc -c hello
./hellozig build-exe hello.zig -O ReleaseSmall --strip --single-threaded
wc -c hello
zig build-exe hello.zig -O ReleaseSmall --strip --single-threaded -target x86_64-macos
wc -c hello
file hello
```### Global variables
```bash
cd global_variables
zig test global_variables.zig
```### Errors
TODO
### Test
```bash
cd test_null
zig test test_null.zig
```### C library (libcurl)
```bash
cd curl
zig build-exe curl.zig
```> See https://ziglearn.org/chapter-4/
### Config
```bash
cd config/
zig build-exe config.zig
./config
```### Comptime
TODO
### Async
TODO
> See https://ziglearn.org/chapter-5/
### Allocator
TODO
> See https://ziglearn.org/chapter-2/#allocators
### Cross compile
```bash
cd cross-compile-arm/
zig targets
zig targets | jq .arch
zig targets | jq .os
zig targets | jq .abi
zig targets | jq .libczig build-exe hello.zig -target armeb-linux-musleabi --library c --strip --single-threaded
file hello
```> See https://ziglearn.org/chapter-3/#cross-compilation
### Benchmarks
```bash
cd benchmark/
./benchmark.sh
```> See https://github.com/Sahnvour/zig-benchmark
> See https://benchmarksgame-team.pages.debian.net/benchmarksgame/why-measure-toy-benchmark-programs.html
> See https://github.com/tiehuis/zig-benchmarks-game## Resources
* https://ziglearn.org/
* https://github.com/ziglang/zig/tree/master/test