diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-04-24 22:31:53 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-04-24 22:31:53 -0400 |
| commit | fb2acaff067dd6b385de7f2bd2726bdfebbf841f (patch) | |
| tree | 1dce5178adc5066eba68510d36baed06575aad0a /doc | |
| parent | 733c547a65b005338c89e3b6a6cb6e817bee632b (diff) | |
| download | zig-fb2acaff067dd6b385de7f2bd2726bdfebbf841f.tar.gz zig-fb2acaff067dd6b385de7f2bd2726bdfebbf841f.zip | |
`@sizeOf` returns 0 for comptime types
This defines `@sizeOf` to be the runtime size of a type, which means
that it is zero for types such as comptime_int, type, and (enum
literal).
See #2209
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/langref.html.in | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/doc/langref.html.in b/doc/langref.html.in index 7217d4786e..7b3d7f3dd1 100644 --- a/doc/langref.html.in +++ b/doc/langref.html.in @@ -7275,6 +7275,10 @@ test "@setRuntimeSafety" { consider whether you want to use {#syntax#}@sizeOf(T){#endsyntax#} or {#syntax#}@typeInfo(T).Int.bits{#endsyntax#}. </p> + <p> + This function measures the size at runtime. For types that are disallowed at runtime, such as + {#syntax#}comptime_int{#endsyntax#} and {#syntax#}type{#endsyntax#}, the result is {#syntax#}0{#endsyntax#}. + </p> {#see_also|@typeInfo#} {#header_close#} |
