Ziggit

Confusion about error: unable to resolve comptime value (opens in new tab)

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 f...

Read the original article
Sign in to keep reading the full article.

Keyboard Shortcuts

Navigation

Next / previous post
j/k
Open post
oorEnter
Preview post
v

Post Actions

Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Save / unsave
s

Recommendations

Add interest / feed
Enter
Not interested
x

Go to

Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Discover
gb
Search
/

General

Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help