Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiled_starters/zig/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Time to move on to the next stage!

Note: This section is for stages 2 and beyond.

1. Ensure you have `zig (0.14)` installed locally
1. Ensure you have `zig (0.15)` installed locally
1. Run `./your_program.sh` to run your program, which is implemented in
`src/main.zig`.
1. Commit your changes and run `git push origin master` to submit your solution
Expand Down
7 changes: 4 additions & 3 deletions compiled_starters/zig/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ const std = @import("std");
pub fn build(b: *std.Build) void {
const exe = b.addExecutable(.{
.name = "main",
.root_source_file = b.path("src/main.zig"),
.target = b.standardTargetOptions(.{}),
.optimize = b.standardOptimizeOption(.{}),
.root_module = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
.target = b.graph.host,
}),
});

// This declares intent for the executable to be installed into the
Expand Down
2 changes: 1 addition & 1 deletion compiled_starters/zig/build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// This field is optional.
// This is currently advisory only; Zig does not yet do anything
// with this value.
.minimum_zig_version = "0.14.0",
.minimum_zig_version = "0.15.1",

// This field is optional.
// Each dependency must either provide a `url` and `hash`, or a `path`.
Expand Down
6 changes: 2 additions & 4 deletions compiled_starters/zig/src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ const std = @import("std");
const net = std.net;

pub fn main() !void {
const stdout = std.io.getStdOut().writer();

// You can use print statements as follows for debugging, they'll be visible when running tests.
try stdout.print("Logs from your program will appear here!\n", .{});
std.debug.print("Logs from your program will appear here!\n", .{});

// Uncomment this block to pass the first stage
// const address = try net.Address.resolveIp("127.0.0.1", 4221);
Expand All @@ -15,5 +13,5 @@ pub fn main() !void {
// defer listener.deinit();
//
// _ = try listener.accept();
// try stdout.print("client connected!", .{});
// std.debug.print("client connected!", .{});
}
2 changes: 1 addition & 1 deletion solutions/zig/01-at4/code/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Time to move on to the next stage!

Note: This section is for stages 2 and beyond.

1. Ensure you have `zig (0.14)` installed locally
1. Ensure you have `zig (0.15)` installed locally
1. Run `./your_program.sh` to run your program, which is implemented in
`src/main.zig`.
1. Commit your changes and run `git push origin master` to submit your solution
Expand Down
7 changes: 4 additions & 3 deletions solutions/zig/01-at4/code/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ const std = @import("std");
pub fn build(b: *std.Build) void {
const exe = b.addExecutable(.{
.name = "main",
.root_source_file = b.path("src/main.zig"),
.target = b.standardTargetOptions(.{}),
.optimize = b.standardOptimizeOption(.{}),
.root_module = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
.target = b.graph.host,
}),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Build Configuration Options Removed

The addExecutable refactor to use root_module removed the target and optimize configuration options. The target is now hardcoded to b.graph.host, which prevents cross-compilation. Additionally, the optimize option is missing, removing the ability to control optimization levels via build flags.

Additional Locations (1)

Fix in Cursor Fix in Web

});

// This declares intent for the executable to be installed into the
Expand Down
2 changes: 1 addition & 1 deletion solutions/zig/01-at4/code/build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// This field is optional.
// This is currently advisory only; Zig does not yet do anything
// with this value.
.minimum_zig_version = "0.14.0",
.minimum_zig_version = "0.15.1",

// This field is optional.
// Each dependency must either provide a `url` and `hash`, or a `path`.
Expand Down
4 changes: 1 addition & 3 deletions solutions/zig/01-at4/code/src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ const std = @import("std");
const net = std.net;

pub fn main() !void {
const stdout = std.io.getStdOut().writer();

const address = try net.Address.resolveIp("127.0.0.1", 4221);
var listener = try address.listen(.{
.reuse_address = true,
});
defer listener.deinit();

_ = try listener.accept();
try stdout.print("client connected!", .{});
std.debug.print("client connected!", .{});
}
10 changes: 4 additions & 6 deletions solutions/zig/01-at4/diff/src/main.zig.diff
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
@@ -1,19 +1,15 @@
@@ -1,17 +1,13 @@
const std = @import("std");
const net = std.net;

pub fn main() !void {
const stdout = std.io.getStdOut().writer();

- // You can use print statements as follows for debugging, they'll be visible when running tests.
- try stdout.print("Logs from your program will appear here!\n", .{});
- std.debug.print("Logs from your program will appear here!\n", .{});
+ const address = try net.Address.resolveIp("127.0.0.1", 4221);
+ var listener = try address.listen(.{
+ .reuse_address = true,
Expand All @@ -21,7 +19,7 @@
- // defer listener.deinit();
- //
- // _ = try listener.accept();
- // try stdout.print("client connected!", .{});
- // std.debug.print("client connected!", .{});
+ _ = try listener.accept();
+ try stdout.print("client connected!", .{});
+ std.debug.print("client connected!", .{});
}
2 changes: 1 addition & 1 deletion solutions/zig/01-at4/explanation.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var listener = try address.listen(.{
defer listener.deinit();

_ = try listener.accept();
try stdout.print("client connected!", .{});
std.debug.print("client connected!", .{});
```

Push your changes to pass the first stage:
Expand Down
7 changes: 4 additions & 3 deletions starter_templates/zig/code/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ const std = @import("std");
pub fn build(b: *std.Build) void {
const exe = b.addExecutable(.{
.name = "main",
.root_source_file = b.path("src/main.zig"),
.target = b.standardTargetOptions(.{}),
.optimize = b.standardOptimizeOption(.{}),
.root_module = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
.target = b.graph.host,
}),
});

// This declares intent for the executable to be installed into the
Expand Down
2 changes: 1 addition & 1 deletion starter_templates/zig/code/build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// This field is optional.
// This is currently advisory only; Zig does not yet do anything
// with this value.
.minimum_zig_version = "0.14.0",
.minimum_zig_version = "0.15.1",

// This field is optional.
// Each dependency must either provide a `url` and `hash`, or a `path`.
Expand Down
6 changes: 2 additions & 4 deletions starter_templates/zig/code/src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ const std = @import("std");
const net = std.net;

pub fn main() !void {
const stdout = std.io.getStdOut().writer();

// You can use print statements as follows for debugging, they'll be visible when running tests.
try stdout.print("Logs from your program will appear here!\n", .{});
std.debug.print("Logs from your program will appear here!\n", .{});

// Uncomment this block to pass the first stage
// const address = try net.Address.resolveIp("127.0.0.1", 4221);
Expand All @@ -15,5 +13,5 @@ pub fn main() !void {
// defer listener.deinit();
//
// _ = try listener.accept();
// try stdout.print("client connected!", .{});
// std.debug.print("client connected!", .{});
}
2 changes: 1 addition & 1 deletion starter_templates/zig/config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
attributes:
required_executable: zig (0.14)
required_executable: zig (0.15)
user_editable_file: src/main.zig
Loading