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.

isFlexibleArrayLen

Returns true if the given array length qualifies as a flexible array member under the current -fstrict-flex-arrays level.

Translator.isFlexibleArrayLen
fn isFlexibleArrayLen(t: *const Translator, len: anytype) bool

File

lib/compiler/translate-c/Translator.zig:4175

Code

fn isFlexibleArrayLen(t: *const Translator, len: anytype) bool {
    return switch (t.strict_flex_arrays) {
        .@"0" => true,
        .@"1" => switch (len) {
            .incomplete => true,
            .fixed => |n| n <= 1,
            else => false,
        },
        .@"2" => switch (len) {
            .incomplete => true,
            .fixed => |n| n == 0,
            else => false,
        },
        .@"3" => len == .incomplete,
    };
}