How to get `std.c._errno()` name

Hello, I’m trying to write program with C library, which uses ioctl to manage SPI interface on the board. So after getting some error via std.c._errno(), I don’t know what represents this number after compilation. How can I transform it to []u8? In C I might use strerror(errno: c_int). Is in Zig any alternatives?

std.posix.errno returns an enum value from the errno. Using @tagName we can get the enum value name.

const errno = ...;
const name: []const u8 = @tagName(std.posix.errno(errno));
1 Like

Works well

std.debug.print("Error: {s}\n", .{@tagName(std.posix.errno(std.c._errno().*))});
1 Like