Hi everyone, I am new to Zig and would really some discussion surrounding this issue I am running into to help me learn – thank you!
My program:
const std = @import(“std”);
const print = std.debug.print;
pub fn main() void {
var count: u32 = 1;
count += 1;
const a1: [count]u8 = @splat(‘A’);
print(“{s}\n”, .{a1});
}
Produces this error:
error: unable to resolve comptime value
const a1: [count]u8 = @splat(‘A’);
note: types must be comptime-known
I wasn’t expecting this because I specified u32 for var count – in that sense, I thought the type is comptime-known. I have learned that a solution to this problem is to define comptime var count = 1, but I don’t understand how that solution contrasts with my current one.
Thank you again for your help ![]()