@OpaqueType

@OpaqueType

@OpaqueType() type

Creates a new type with an unknown (but non-zero) size and alignment.

This is typically used for type safety when interacting with C code that does not expose struct details. Example:

test.zig

const Derp = @OpaqueType();
const Wat = @OpaqueType();

extern fn bar(d: *Derp) void;
fn foo(w: *Wat) callconv(.C) void {
    bar(w);
}

test "call foo" {
    foo(undefined);
}
``` ```
$ zig test test.zig
./docgen_tmp/test.zig:6:9: error: expected type '*Derp', found '*Wat'
    bar(w);
        ^
./docgen_tmp/test.zig:6:9: note: pointer type child 'Wat' cannot cast into pointer type child 'Derp'
    bar(w);
        ^