Zig 0.17.0-dev (Split by item)

This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig library itself.

FlexibleArrayType

Constructs a [*c] pointer with the const and volatile annotations from SelfType for pointing to a C flexible array of ElementType.

helpers.FlexibleArrayType
pub fn FlexibleArrayType(comptime SelfType: type, comptime ElementType: type) type

File

Code

pub fn FlexibleArrayType(comptime SelfType: type, comptime ElementType: type) type {
    switch (@typeInfo(SelfType)) {
        .pointer => |ptr| {
            return @Pointer(.c, .{
                .@"const" = ptr.is_const,
                .@"volatile" = ptr.is_volatile,
                .@"allowzero" = true,
                .@"addrspace" = .generic,
                .@"align" = null,
            }, ElementType, null);
        },
        else => |info| @compileError("Invalid self type \"" ++ @tagName(info) ++ "\" for flexible array getter: " ++ @typeName(SelfType)),
    }
}