diff options
| author | Tadeo Kondrak <me@tadeo.ca> | 2020-09-26 09:05:11 -0600 |
|---|---|---|
| committer | Tadeo Kondrak <me@tadeo.ca> | 2020-10-06 22:08:29 -0600 |
| commit | 6b8ae6fffb71128169de447851244869aebb882b (patch) | |
| tree | 74039c5f75002c6f2ec4ec1d2c98278e2a59c2fa /doc | |
| parent | 0a563902305369ca298f5b2d360be55f4d5a95e8 (diff) | |
| download | zig-6b8ae6fffb71128169de447851244869aebb882b.tar.gz zig-6b8ae6fffb71128169de447851244869aebb882b.zip | |
langref: update for opaque {} syntax
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/docgen.zig | 1 | ||||
| -rw-r--r-- | doc/langref.html.in | 15 |
2 files changed, 9 insertions, 7 deletions
diff --git a/doc/docgen.zig b/doc/docgen.zig index 50523d0948..52f373f5b1 100644 --- a/doc/docgen.zig +++ b/doc/docgen.zig @@ -808,6 +808,7 @@ fn tokenizeAndPrintRaw(docgen_tokenizer: *Tokenizer, out: anytype, source_token: .Keyword_noalias, .Keyword_noinline, .Keyword_nosuspend, + .Keyword_opaque, .Keyword_or, .Keyword_orelse, .Keyword_packed, diff --git a/doc/langref.html.in b/doc/langref.html.in index 690614ff99..021fc76289 100644 --- a/doc/langref.html.in +++ b/doc/langref.html.in @@ -1988,7 +1988,7 @@ test "null terminated array" { <li>Supports slice syntax: {#syntax#}ptr[start..end]{#endsyntax#}</li> <li>Supports pointer arithmetic: {#syntax#}ptr + x{#endsyntax#}, {#syntax#}ptr - x{#endsyntax#}</li> <li>{#syntax#}T{#endsyntax#} must have a known size, which means that it cannot be - {#syntax#}c_void{#endsyntax#} or any other {#link|opaque type|Opaque Types#}.</li> + {#syntax#}c_void{#endsyntax#} or any other {#link|opaque type|opaque#}.</li> </ul> </li> </ul> @@ -5545,7 +5545,7 @@ test "turn HashMap into a set with void" { </p> <p> {#syntax#}void{#endsyntax#} is distinct from {#syntax#}c_void{#endsyntax#}, which is defined like this: - {#syntax#}pub const c_void = @Type(.Opaque);{#endsyntax#}. + {#syntax#}pub const c_void = opaque {};{#endsyntax#}. {#syntax#}void{#endsyntax#} has a known size of 0 bytes, and {#syntax#}c_void{#endsyntax#} has an unknown, but non-zero, size. </p> <p> @@ -8471,7 +8471,7 @@ test "integer truncation" { <li>{#link|Error Set Type#}</li> <li>{#link|Error Union Type#}</li> <li>{#link|Vectors#}</li> - <li>{#link|Opaque Types#}</li> + <li>{#link|opaque#}</li> <li>{#link|@Frame#}</li> <li>{#syntax#}anyframe{#endsyntax#}</li> <li>{#link|struct#}</li> @@ -8547,17 +8547,18 @@ fn foo(comptime T: type, ptr: *T) T { {#header_close#} {#header_close#} - {#header_open|Opaque Types#} + {#header_open|opaque#} <p> - {#syntax#}@Type(.Opaque){#endsyntax#} creates a new type with an unknown (but non-zero) size and alignment. + {#syntax#}opaque {}{#endsyntax#} declares a new type with an unknown (but non-zero) size and alignment. + It can have declarations like structs, unions, or enums. </p> <p> This is typically used for type safety when interacting with C code that does not expose struct details. Example: </p> {#code_begin|test_err|expected type '*Derp', found '*Wat'#} -const Derp = @Type(.Opaque); -const Wat = @Type(.Opaque); +const Derp = opaque {}; +const Wat = opaque {}; extern fn bar(d: *Derp) void; fn foo(w: *Wat) callconv(.C) void { |
