In this repository, you will find code samples for each chapter of the book. The book mentions the name of each file, which corresponds to the respective file in this repository.
- Chapter 01: Introduction
- Chapter 02: The Basics
- Chapter 03: Functions
- Chapter 04: Arrays and Slices
- Chapter 05: Struct, Enums and Unions
- Chapter 06: Pointers and Memory Management
- Chapter 07: Error Handling
- Chapter 08: Interfacing with C
- Chapter 09: Advance Topics
It is recommended to use a linux
operating system as we use Makefile
extensively throughout this repository, however, you may use Windows
(recommended to use zig cc/c++
as the C/C++
compiler respectively).
Required:
zig
:v0.11.0
rustc
:> v1.63
clang/gcc
:v13.0.0/v11.4.0
g++
:v11.4.0
make
:v4.3
For ch09
's cross-compilation you will need the following if you would like to target the Raspberry Pi 4:
Dependencies:
$ sudo apt install gcc-arm-linux-gnueabihf binutils-arm-linux-gnueabihf binutils-arm-linux-gnueabihf-dbg qemu-user
Rust target: rustup target add armv7-unknown-linux-gnueabihf
Language | Number of Files | Total Lines |
---|---|---|
Zig | 1 | 8 |
Total | 1 | 8 |
Language | Number of Files | Total Lines |
---|---|---|
Zig | 15 | 328 |
C | 1 | 16 |
Rust | 1 | 9 |
Total | 17 | 353 |
Language | Number of Files | Total Lines |
---|---|---|
Zig | 13 | 269 |
C | 2 | 43 |
Rust | 1 | 16 |
C++ | 1 | 22 |
Total | 17 | 350 |
Language | Number of Files | Total Lines |
---|---|---|
Zig | 25 | 454 |
C | 3 | 123 |
Total | 28 | 577 |
Language | Number of Files | Total Lines |
---|---|---|
Zig | 10 | 227 |
C | 3 | 82 |
C++ | 1 | 31 |
Total | 14 | 340 |
Language | Number of Files | Total Lines |
---|---|---|
Zig | 17 | 2126 |
C | 9 | 93 |
Total | 26 | 2219 |
Language | Number of Files | Total Lines |
---|---|---|
C++ | 1 | 18 |
Zig | 1 | 20 |
Rust | 1 | 21 |
Total | 3 | 59 |
Language | Number of Files | Total Lines |
---|---|---|
C | 4 | 258 |
Zig | 4 | 22062 |
Total | 8 | 22320 |
Language | Number of Files | Total Lines |
---|---|---|
Rust | 2 | 6 |
C | 1 | 6 |
Zig | 3 | 99 |
Total | 6 | 111 |