Set page_size_max for freestanding

I’m working on a zig project for a Raspberry Pi Pico. The project uses the Pico C SDK, so not a MicroZig project (the code is here: GitHub - ADIX7/zig-pico-doorbell).

I managed to make a blinking example work but as a next step I wanted to add some code that requires allocating memory. I tried to use the std.heap.GeneralPurposeAllocator but I got a compilation error:

└─ zig build-obj zig-pico Debug thumb-freestanding-eabi 1 errors
/home/linuxbrew/.linuxbrew/Cellar/zig/0.14.0_1/lib/zig/std/heap.zig:56:5: error: freestanding/other page_size_max must provided with std.options.page_size_max
    @compileError("freestanding/other page_size_max must provided with std.options.page_size_max")

Is there a way to set std.options.page_size_max somehow? Or is there a bigger problem here?

https://ziglang.org/documentation/master/#Standard-Library-Options

You should put this to your root module:

pub const std_options: std.Options = .{
    .page_size_max = ...
};
3 Likes

Oh, nice, thank you!

1 Like