Type Function FlexibleArrayType [src]
Constructs a [*c] pointer with the const and volatile annotations
from SelfType for pointing to a C flexible array of ElementType.
Prototype
pub fn FlexibleArrayType(comptime SelfType: type, comptime ElementType: type) type
Parameters
SelfType: type
ElementType: type
Source
pub fn FlexibleArrayType(comptime SelfType: type, comptime ElementType: type) type {
switch (@typeInfo(SelfType)) {
.pointer => |ptr| {
return @Type(.{ .pointer = .{
.size = .c,
.is_const = ptr.is_const,
.is_volatile = ptr.is_volatile,
.alignment = @alignOf(ElementType),
.address_space = .generic,
.child = ElementType,
.is_allowzero = true,
.sentinel_ptr = null,
} });
},
else => |info| @compileError("Invalid self type \"" ++ @tagName(info) ++ "\" for flexible array getter: " ++ @typeName(SelfType)),
}
}