authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-04-06 19:14:49-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-04-08 18:03:09-04:00
logeae355d77168d655273afa298dc921c40a36bd0b
treedca3ff52f25d49f67252da9e3ce25f9c0b9fea21
parentfef06f2142a0f7ec65d3500aff509c74d89bf63b

add docs for packed enum


1 files changed, 18 insertions(+), 2 deletions(-)

doc/langref.html.in+18-2
...@@ -1947,8 +1947,24 @@ const Foo = extern enum { A, B, C };...@@ -1947,8 +1947,24 @@ const Foo = extern enum { A, B, C };
1947export fn entry(foo: Foo) void { }1947export fn entry(foo: Foo) void { }
1948 {#code_end#}1948 {#code_end#}
1949 {#header_close#}1949 {#header_close#}
1950 <p>TODO packed enum</p>1950 {#header_open|packed enum#}
1951 {#see_also|@memberName|@memberCount|@tagName#}1951 <p>By default, the size of enums is not guaranteed.</p>
1952 <p><code>packed enum</code> causes the size of the enum to be the same as the size of the integer tag type
1953 of the enum:</p>
1954 {#code_begin|test#}
1955const std = @import("std");
1956
1957test "packed enum" {
1958 const Number = packed enum(u8) {
1959 One,
1960 Two,
1961 Three,
1962 };
1963 std.debug.assert(@sizeOf(Number) == @sizeOf(u8));
1964}
1965 {#code_end#}
1966 {#header_close#}
1967 {#see_also|@memberName|@memberCount|@tagName|@sizeOf#}
1952 {#header_close#}1968 {#header_close#}
1953 {#header_open|union#}1969 {#header_open|union#}
1954 {#code_begin|test|union#}1970 {#code_begin|test|union#}