diff --git a/doc/langref.html.in b/doc/langref.html.in index 3e335c8d64..fa649ebf25 100644 --- a/doc/langref.html.in +++ b/doc/langref.html.in @@ -1885,7 +1885,7 @@ test "null terminated array" {
{#syntax#}void{#endsyntax#} is distinct from {#syntax#}c_void{#endsyntax#}, which is defined like this: - {#syntax#}pub const c_void = @OpaqueType();{#endsyntax#}. + {#syntax#}pub const c_void = @Type(.Opaque);{#endsyntax#}. {#syntax#}void{#endsyntax#} has a known size of 0 bytes, and {#syntax#}c_void{#endsyntax#} has an unknown, but non-zero, size.
@@ -7666,30 +7666,6 @@ mem.set(u8, dest, c);{#endsyntax#}
{#header_close#} - {#header_open|@OpaqueType#} -{#syntax#}@OpaqueType() type{#endsyntax#}
- - 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: -
- {#code_begin|test_err|expected type '*Derp', found '*Wat'#} -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); -} - {#code_end#} - {#header_close#} - {#header_open|@panic#}{#syntax#}@panic(message: []const u8) noreturn{#endsyntax#}
@@ -8274,21 +8250,21 @@ test "integer truncation" {
For these types it is a TODO in the compiler to implement:
@@ -8373,6 +8349,28 @@ fn foo(comptime T: type, ptr: *T) T { {#header_close#} {#header_close#} + {#header_open|Opaque Types#} + {#syntax#}@Type(.Opaque){#endsyntax#} 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: +
+ {#code_begin|test_err|expected type '*Derp', found '*Wat'#} +const Derp = @Type(.Opaque); +const Wat = @Type(.Opaque); + +extern fn bar(d: *Derp) void; +fn foo(w: *Wat) callconv(.C) void { + bar(w); +} + +test "call foo" { + foo(undefined); +} + {#code_end#} + {#header_close#} + {#header_open|Build Mode#}Zig has four build modes: