mirror of
https://github.com/ziglang/zig.git
synced 2024-11-15 00:26:57 +00:00
doc: recommend optional pointers for nullptrs instead of allowzero
This commit is contained in:
parent
0ccd91faea
commit
6d73e5de05
@ -2026,9 +2026,9 @@ fn foo(bytes: []u8) u32 {
|
||||
{#header_open|allowzero#}
|
||||
<p>
|
||||
This pointer attribute allows a pointer to have address zero. This is only ever needed on the
|
||||
freestanding OS target, where the address zero is mappable. In this code example, if the pointer
|
||||
did not have the {#syntax#}allowzero{#endsyntax#} attribute, this would be a
|
||||
{#link|Pointer Cast Invalid Null#} panic:
|
||||
freestanding OS target, where the address zero is mappable. If you want to represent null pointers, use
|
||||
{#link|Optional Pointers#} instead. In this code example, if the pointer did not have the
|
||||
{#syntax#}allowzero{#endsyntax#} attribute, this would be a {#link|Pointer Cast Invalid Null#} panic:
|
||||
</p>
|
||||
{#code_begin|test|allowzero#}
|
||||
const std = @import("std");
|
||||
|
Loading…
Reference in New Issue
Block a user