mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 05:44:20 +00:00
The rule: `pub fn main` owns file descriptors 0, 1, and 2. If you didn't write `pub fn main()` it is, in general, not your business to print to stderr.
22 lines
382 B
Zig
22 lines
382 B
Zig
const std = @import("std");
|
|
const expect = std.testing.expect;
|
|
const print = std.debug.print;
|
|
|
|
pub fn main() void {
|
|
print("\n", .{});
|
|
|
|
defer {
|
|
print("1 ", .{});
|
|
}
|
|
defer {
|
|
print("2 ", .{});
|
|
}
|
|
if (false) {
|
|
// defers are not run if they are never executed.
|
|
defer {
|
|
print("3 ", .{});
|
|
}
|
|
}
|
|
}
|
|
|
|
// exe=succeed
|