Static keyword for creating buffers in data

fn execSys() void {
    var path_buff: [MAX_PATH]u8 = undefined;
    const proc = Process.currentOrPanic();
    const path_user_address = proc.trapframe.?.a0;
    proc.pagetable.?.copyFrom(path_user_address, @ptrCast(&path_buff), MAX_PATH) catch |e| {
        lib.kpanic("Failed to copy path from user to kernel");

    exec(@ptrCast(&path_buff)) catch |e| {
        lib.kpanic("Failed to exec /init");

I currently have to globally define it and add the function name to the var name
I get errors with stack when defining path buff locally. is there no way to add a static tag to this variable, instead of using a struct definition? it doesn’t really make sense and isn’t that readable.

You can find an example of static lifetime variables in Static Local Variables
See also the answers to the thread: Global variables vs Static variables

1 Like