Skip to main content
Filter by
Sorted by
Tagged with
-1 votes
1 answer
68 views

I want to modify or compute a value before assigning it to a const. Is there a way to do this in a single line expression? I can use labeled block syntax, but I’m wondering if there’s another syntax ...
Phuwadon Verasertniyom's user avatar
-1 votes
1 answer
86 views

Is there a Zig equivalent of a C# Dictionary or a Java Map or a Go map that stores key/value pairs in a structured way? If so, how do I create one?
zacoons's user avatar
  • 380
-2 votes
0 answers
90 views

Zig language (0.16) has a library for ASN.1 very extended, but trying to encode a slice within a struct and I got an comptime error. I dived into the code and find out (with gemini's help) that ....
chasques's user avatar
  • 136
-1 votes
1 answer
158 views

I am trying to implement color blending in the fragment shader because I want to use the alpha channel as a sort of dynamic stencil buffer for future draw calls. I have attached the swapchain image ...
Jim Morrison's user avatar
7 votes
1 answer
244 views

I believe that it should be possible to use zig to compile a simple c library to web assembly. I am using the following c code // add.c int add (int first, int second) { return first + second; } ...
Koisto's user avatar
  • 135
0 votes
1 answer
95 views

Trying to add to smaller values and save them into a larger variable type with this code: const a: u4 = 0b1101; const b: u4 = 0b0101; const c: u5 = @intCast(a) + @intCast(b); ...does not ...
run_the_race's user avatar
  • 2,550
0 votes
1 answer
96 views

I need to append candlestick bars to Duckdb that have a timestamp data type. Since I don't know how I have used varchar for time instead. How do I do it properly so that I can query based on timestamp?...
lele1c's user avatar
  • 72
5 votes
1 answer
216 views

I'm trying to link a zig static library with golang. here is my build.zig const std = @import("std"); pub fn build(b: *std.Build) void { const windows = b.option(bool, "windows&...
vuzzie's user avatar
  • 133
3 votes
1 answer
253 views

I'm learning Zig and I'm trying to write a generic function that automatically serializes any struct into JSON. In languages like Rust or Go, there are libraries that can iterate over the fields of a ...
Ronika Kashyap's user avatar
2 votes
1 answer
83 views

im making an os kernel in zig (grub to boot) and im trying to get interrupts to work specifically hardware interrupts and as soon as i enable them (i have a pic, gdt and idt setup) it gives me a ...
Crazy games's user avatar
2 votes
1 answer
128 views

In the below code, I have the function "get_specific_files". The objective of this function is to check if certain filenames contain some word, and then return all the files that contain ...
fwamingo 273's user avatar
2 votes
1 answer
91 views

I'm writing a UEFI application in Zig. I'm calling GetMemoryMap() twice: once to get the required buffer size, then again after allocating the buffer using AllocatePool(). Here's my code: fn ...
OrderChaos's user avatar
0 votes
1 answer
82 views

I am trying to make a sort of input() function for a project I've been working on. The function simply reads from stdin and returns the string. Here's what I came up with: const std = @import("...
GabrieleC0's user avatar
0 votes
0 answers
160 views

I know MultiArrayList supports tagged union, but it does it by converting it into struct containing untagged union and a tag field, effectively creating 2 ArrayList fields, one for union and the other ...
Krischal Khanal's user avatar
0 votes
0 answers
138 views

Does zig support compiler/linker functionality similar to that of gcc when using the -Wl,--wrap option? I am new to zig and admit I'm probably just doing it wrong. For instance I have a C only project ...
krispy86's user avatar
1 vote
1 answer
84 views

On a pet project of mine, I'm trying to create a pointer to an expression using the arena allocator along with the heap page allocator, but I'm encountering some issues. The expression is defined as a ...
fabinho's user avatar
  • 31
0 votes
1 answer
72 views

I'm working on a new pet project and i came across this error when trying to store functions in a hash in zig. the error happens on the try p.nud_handlers.put(Tokens.IDENT, p.parseIdentifier); line ...
fabinho's user avatar
  • 31
2 votes
1 answer
157 views

It seems that "zig build test" will run the unit tests automatically, but I want to generate an executable file which calls all the unit test functions, then I would like to load the ...
Felix F Xu's user avatar
0 votes
2 answers
155 views

I have the following code const std = @import("std"); const stdio = @cImport({ @cInclude("stdio.h"); }); const ioctl = @cImport({ @cInclude("sys/ioctl.h"); @...
Ethan McCue's user avatar
  • 1,036
3 votes
1 answer
266 views

I'm using std.log in Zig and I want to change the log level (e.g. to .debug or .info) when running tests using the command line. Is there a way to set the log level from zig build, for example like: ...
Filippo Zanelli's user avatar
0 votes
1 answer
444 views

using zig, I need to generate a timestamp that format exactly or almost matches 2025-04-18T14:03:52.000Z. How can I go about it? using the standard library only
mbithi's user avatar
  • 35
2 votes
1 answer
251 views

I'm trying to use Zig's logging functionality within my tests, but when I run the tests using the command zig build test --summary all, I don't see the log messages I expect. What I've tried: I've set ...
Filippo Zanelli's user avatar
0 votes
1 answer
417 views

During the study and practice of optionals and pointers in Zig, I encountered behavior that was quite unclear to me. I can't quite understand what exactly the compiler is trying to tell me. In the ...
YeO's user avatar
  • 3
0 votes
1 answer
132 views

I'm using zig 0.14.0, and having issues with setting a nullable array. I've come up with an example (this is not my main code base or anything close to what I'm doing) to illustrate the issue. const ...
AdmiralJonB's user avatar
  • 2,142
3 votes
1 answer
285 views

I'm building a Go application with native (CGO_ENABLED=1) SQLite support using https://github.com/mattn/go-sqlite3. I'm trying to get the builder docker image to a reasonable size. (goreleaser/...
user3277119's user avatar
1 vote
1 answer
143 views

I am trying to write a simple window manager with xcb in zig where there is an event loop with some possible events (key press, ...). My system is running an arch linux and all the necessary libraries ...
mortimer's user avatar
0 votes
0 answers
122 views

I am completely new to zig and system programming. I do not understand anything from the zig build system and I want to include glfw and xcb.zig in my project. I have been looking for documentations ...
mortimer's user avatar
1 vote
1 answer
128 views

Without altering func()'s signature, How am I able to do something like this? const std = @import("std"); fn runtimeNumber() u16 { return 32; } fn func(b: [4]u8) void { std.debug....
sloweax's user avatar
  • 55
1 vote
0 answers
107 views

I want to place jump to my function on address of other function declaration, specifically CreatePen function for gdi. I'm using zig and that's what i've made so far: const windows = @import("std&...
Nazar's user avatar
  • 11
3 votes
1 answer
243 views

I am writing a webassembly demo in C to match a similar demo I wrote in zig. I am currently able to call C functions from JS, and interact with shared memory on either side. However, I can't seem to ...
J. B's user avatar
  • 129
0 votes
1 answer
119 views

I noticed that a library I'm using frequently returns []const u8 instead of []u8 when it allocates memory and the caller is responsible for freeing it. Should a function return a mutable slice []u8 ...
Luke W.'s user avatar
  • 63
1 vote
1 answer
233 views

When cross-compiling for RISC-V with Zig I believe you do something like this: pub fn build(b: *std.Build) void { const target = b.resolveTargetQuery(.{ .cpu_arch = .riscv32, .abi =...
Timmmm's user avatar
  • 99.2k
1 vote
1 answer
271 views

The remap function in Zig's memory allocator interface is supposed to "attempt to expand or shrink memory, allowing relocation". In particular, it mentions that... A null return value ...
wildcat's user avatar
  • 81
1 vote
1 answer
342 views

I'm trying to learn Zig using the website https://exercism.org/. I was solving this exercise, which requires us to find the nth prime number. My idea was to generate all of them during comptime and ...
João Areias's user avatar
  • 1,530
2 votes
1 answer
124 views

I'm trying to learn Zig using the website https://exercism.org/. I was solving this exercise, which requires us to find the nth prime number. My idea was to generate all of them during comptime and ...
João Areias's user avatar
  • 1,530
0 votes
2 answers
102 views

I don't know if this is correct behavior according to the author, or if there's a mistake in compilation. const std = @import("std"); const expect = std.testing.expect; const expectError = ...
agatzan's user avatar
  • 21
2 votes
1 answer
182 views

I'm new to Zig and have been going through some premade exercises to get a hang of it. I got stuck on one because I misunderstood what the compiler was trying to tell me. I've mocked up a sample of ...
Brandon Lewallen's user avatar
6 votes
1 answer
700 views

Dabbling with Zig and have a question about const fields in structs. In the simple struct below I have started to implement a simple matrix data structure. Presumably once I have instantiated a ...
broken.eggshell's user avatar
1 vote
1 answer
493 views

I'm trying to learn Zig v0.13.0, and I'm playing around with small programs. While playing, I tried to create a "global allocator", which is more convenient for now. So at first, I did ...
Ladislus's user avatar
  • 127
4 votes
1 answer
159 views

I'm having trouble with memory management in Zig (using v0.13.0), regarding global and static local variables deinitialization. I've written the following program, but memory leaks, and thus the ...
Ladislus's user avatar
  • 127
1 vote
1 answer
306 views

Given the following C code: // h.h typedef enum E { A, B, C } E; Zig translates this to pub const A: c_int = 0; pub const B: c_int = 1; pub const C: c_int = 2; pub const enum_E = c_uint; pub ...
Max Coplan's user avatar
  • 1,593
0 votes
1 answer
770 views

I am attempting to parse a .json file in zig however am very new to zig and having no luck finding much documentation for this. Here is my working example of code: const std = @import("std");...
Aria Lopez's user avatar
-2 votes
1 answer
573 views

See the following code const std = @import("std"); const print = std.debug.print; test "Demo accumulation" { const accumulated = try accumulate(); print("DEBUG - ...
scubbo's user avatar
  • 5,987
0 votes
1 answer
1k views

As part of testing my solution to Advent Of Code 2024 day 5, I'm trying to create a struct containing an array created from an literal, but I'm getting an error that I can't resolve: const std = @...
scubbo's user avatar
  • 5,987
0 votes
2 answers
1k views

I am very new to Zig (working through Advent Of Code in it), and I am very confused by its handling of strings (or, I should say, []u8s) as function arguments and return types. TL;DR what is the ...
scubbo's user avatar
  • 5,987
1 vote
0 answers
117 views

I have a notification icon app in zig using Win32 API. It has this code as its WndProc: const std = @import("std"); const windows = std.os.windows; const zeroes = std.mem.zeroes; pub const ...
Tzero Ocne's user avatar
0 votes
1 answer
206 views

I'm new to Zig and experimenting with the type system. I have a piece of code that does some comptime operations to determine the shape of a tensor. I'd like to use this comptime variable for some ...
financial_physician's user avatar
1 vote
1 answer
48 views

Im trying to read the header of a wav file ( wav file that works with media players) in my program, but i only find invalid values ( for sample rate, number of channels ect) pub const WavObject = ...
Nicolas Boudier's user avatar
1 vote
1 answer
374 views

I am trying to produce a struct that holds references to each of the readers and writers of stdin/stdout/stderr I am stuck at trying to declare the appropriate types however. My simplest code: const ...
tk-noodle's user avatar
  • 402
2 votes
1 answer
215 views

I'm using a simple github actions to try to build some ELF binaries using windows-latest just to check if it works: https://github.com/libriscv/godot-sandbox-programs/blob/windows/.github/workflows/...
gonzo's user avatar
  • 567

1
2 3 4 5
10