Skip to content

Commit

Permalink
Explain why enum is isize
Browse files Browse the repository at this point in the history
  • Loading branch information
shadaj committed Jul 23, 2021
1 parent cd4629d commit 9aeec92
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions tool/src/c/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ fn gen_type<W: fmt::Write>(
}

ast::CustomType::Enum(_) => {
// repr(C) fieldless enums use the default platform representation: isize
write!(out, "ssize_t")?;
}
},
Expand Down
5 changes: 4 additions & 1 deletion tool/src/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ pub fn type_size_alignment(
(size, max_align)
}

ast::CustomType::Enum(_) => (4, 4),
ast::CustomType::Enum(_) => {
// repr(C) fieldless enums use the default platform representation: isize
(4, 4)
},

ast::CustomType::Opaque(_) => {
panic!("Size of opaque types is unknown")
Expand Down

0 comments on commit 9aeec92

Please sign in to comment.