Hi, I want write my zig code and debug it while I write it. One of the things this cause is I do not want variables to be optimized away while I write them. Is there a way to ensure this with the build?
My file looks something like this.
const std = @import("std");
fn readEntireFile(filename: []const u8) !void {
const file = try std.fs.cwd().openFile(filename, .{});
const stat = try file.stat();
_ = stat; // I include a breakpoint here in VScode to debug.
}
test {
_ = try readEntireFile("data_1_flex.json");
}
The thing stat gets optimized away. How can I prevent this? Right now the only thing that worked was adding.
std.debug.print("{d}", .{stat.mode});
But I'd prefer not to.