Skip to content

Commit

Permalink
Use __alignof on MSVC
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcrichton committed Sep 16, 2015
1 parent b1d0e03 commit 63ff2b4
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,10 +460,15 @@ impl<'a> Generator<'a> {
}

fn test_size_align(&mut self, rust: &str, c: &str) {
let align_of = if self.target.contains("msvc") {
"__alignof"
} else {
"__alignof__"
};
t!(writeln!(self.c, r#"
uint64_t __test_size_{ty}(void) {{ return sizeof({cty}); }}
uint64_t __test_align_{ty}(void) {{ return __alignof__({cty}); }}
"#, ty = rust, cty = c));
uint64_t __test_align_{ty}(void) {{ return {align_of}({cty}); }}
"#, ty = rust, cty = c, align_of = align_of));
t!(writeln!(self.rust, r#"
fn size_align_{ty}() {{
extern {{
Expand Down

0 comments on commit 63ff2b4

Please sign in to comment.