mirror of
https://codeberg.org/andyscott/ziglings.git
synced 2024-12-22 14:03:10 -05:00
Merge pull request #189 from chrboesch/dev1650
check for dev1650 and some minor polish
This commit is contained in:
commit
f9b3d50824
6 changed files with 12 additions and 9 deletions
|
@ -27,6 +27,7 @@ or a "systems" level language such as C.
|
||||||
Each exercise is self-contained and self-explained. However, you're encouraged
|
Each exercise is self-contained and self-explained. However, you're encouraged
|
||||||
to also check out these Zig language resources for more detail:
|
to also check out these Zig language resources for more detail:
|
||||||
|
|
||||||
|
* https://ziglang.org/learn/
|
||||||
* https://ziglearn.org/
|
* https://ziglearn.org/
|
||||||
* https://ziglang.org/documentation/master/
|
* https://ziglang.org/documentation/master/
|
||||||
|
|
||||||
|
@ -41,7 +42,7 @@ Verify the installation and build number of `zig` like so:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ zig version
|
$ zig version
|
||||||
0.11.0-dev.1638+xxxxxxxxx
|
0.11.0-dev.1650+xxxxxxxxx
|
||||||
```
|
```
|
||||||
|
|
||||||
Clone this repository with Git:
|
Clone this repository with Git:
|
||||||
|
@ -81,7 +82,7 @@ about input:
|
||||||
|
|
||||||
### Version Changes
|
### Version Changes
|
||||||
|
|
||||||
Version-0.11.0-dev.1638+xxxxxxxxx
|
Version-0.11.0-dev.1650+xxxxxxxxx
|
||||||
* *2023-02-12* zig 0.11.0-dev.1638 - changes in `std.Build` cache_root now returns a directory struct
|
* *2023-02-12* zig 0.11.0-dev.1638 - changes in `std.Build` cache_root now returns a directory struct
|
||||||
* *2023-02-04* zig 0.11.0-dev.1568 - changes in `std.Build` (combine `std.build` and `std.build.Builder` into `std.Build`)
|
* *2023-02-04* zig 0.11.0-dev.1568 - changes in `std.Build` (combine `std.build` and `std.build.Builder` into `std.Build`)
|
||||||
* *2023-01-14* zig 0.11.0-dev.1302 - changes in `@addWithOverflow` (now returns a tuple) and `@typeInfo`; temporary disabled async functionality
|
* *2023-01-14* zig 0.11.0-dev.1302 - changes in `@addWithOverflow` (now returns a tuple) and `@typeInfo`; temporary disabled async functionality
|
||||||
|
@ -166,6 +167,7 @@ Core Language
|
||||||
* [ ] Async <--- IN PROGRESS!
|
* [ ] Async <--- IN PROGRESS!
|
||||||
* [X] Interfaces
|
* [X] Interfaces
|
||||||
* [X] Working with C
|
* [X] Working with C
|
||||||
|
* [ ] String formating
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ const print = std.debug.print;
|
||||||
// When changing this version, be sure to also update README.md in two places:
|
// When changing this version, be sure to also update README.md in two places:
|
||||||
// 1) Getting Started
|
// 1) Getting Started
|
||||||
// 2) Version Changes
|
// 2) Version Changes
|
||||||
const needed_version = std.SemanticVersion.parse("0.11.0-dev.1638") catch unreachable;
|
const needed_version = std.SemanticVersion.parse("0.11.0-dev.1650") catch unreachable;
|
||||||
|
|
||||||
const Exercise = struct {
|
const Exercise = struct {
|
||||||
/// main_file must have the format key_name.zig.
|
/// main_file must have the format key_name.zig.
|
||||||
|
|
|
@ -7,9 +7,9 @@ const std = @import("std");
|
||||||
|
|
||||||
// Take note that this main() definition now returns "!void" rather
|
// Take note that this main() definition now returns "!void" rather
|
||||||
// than just "void". Since there's no specific error type, this means
|
// than just "void". Since there's no specific error type, this means
|
||||||
// that Zig will infer the error type. This is appropriate in the
|
// that Zig will infer the error type. This is appropriate in the case
|
||||||
// case of main(), but can make a function harder (function pointers)
|
// of main(), but can make a function harder (function pointers) or
|
||||||
// or even impossible to work with (recursion) in some situations.
|
// even impossible to work with (recursion) in some situations.
|
||||||
//
|
//
|
||||||
// You can find more information at:
|
// You can find more information at:
|
||||||
// https://ziglang.org/documentation/master/#Inferred-Error-Sets
|
// https://ziglang.org/documentation/master/#Inferred-Error-Sets
|
||||||
|
|
|
@ -53,8 +53,8 @@ pub fn main() void {
|
||||||
// specify a file descriptor i.e. 2 for error console.
|
// specify a file descriptor i.e. 2 for error console.
|
||||||
//
|
//
|
||||||
// In this exercise we use 'write' to output 17 chars,
|
// In this exercise we use 'write' to output 17 chars,
|
||||||
// but something is missing...
|
// but something is still missing...
|
||||||
const c_res = ???write(2, "Hello C from Zig!", 17);
|
const c_res = write(2, "Hello C from Zig!", 17);
|
||||||
|
|
||||||
// let's see what the result from C is:
|
// let's see what the result from C is:
|
||||||
std.debug.print(" - C result ist {d} chars written.\n", .{c_res});
|
std.debug.print(" - C result ist {d} chars written.\n", .{c_res});
|
||||||
|
|
|
@ -29,5 +29,6 @@ pub fn main() !void {
|
||||||
// Here we call the C function 'fmod' to get our normalized angel.
|
// Here we call the C function 'fmod' to get our normalized angel.
|
||||||
const result = c.fmod(angel, circle);
|
const result = c.fmod(angel, circle);
|
||||||
|
|
||||||
|
// We use formatters for the desired precision and to truncate the decimal places
|
||||||
std.debug.print("The normalized angle of {d: >3.1} degrees is {d: >3.1} degrees.\n", .{ angel, result });
|
std.debug.print("The normalized angle of {d: >3.1} degrees is {d: >3.1} degrees.\n", .{ angel, result });
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
57c57
|
57c57
|
||||||
< const c_res = ???write(2, "Hello C from Zig!", 17);
|
< const c_res = write(2, "Hello C from Zig!", 17);
|
||||||
---
|
---
|
||||||
> const c_res = c.write(2, "Hello C from Zig!", 17);
|
> const c_res = c.write(2, "Hello C from Zig!", 17);
|
||||||
|
|
Loading…
Reference in a new issue