Skip to content

Commit

Permalink
emitter: do not cast const
Browse files Browse the repository at this point in the history
this loosens hygiene a little but some C compilers can't figure out
a cast to the same type is constant (gcc7)
  • Loading branch information
aep committed Aug 26, 2020
1 parent cf3bd09 commit 52640db
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -545,14 +545,20 @@ impl Emitter {
self.inside_macro = true;
write!(
self.f,
"#define {} ((",
"#define {} (",
self.to_local_name(&Name::from(&ast.name))
)
.unwrap();
write!(self.f, "{} ", self.to_local_typed_name(&typed)).unwrap();
self.emit_pointer(&typed.ptr);

// gcc doesnt like this. if we want it back,
// it needs to be conditionally disabled if it would cast to the same type
/*
write!(self.f, "({} ", self.to_local_typed_name(&typed)).unwrap();
self.emit_pointer(&typed.ptr);
write!(self.f, ")").unwrap();
*/


self.emit_expr(&expr);
write!(self.f, ")\n").unwrap();

Expand Down Expand Up @@ -1505,9 +1511,9 @@ impl Emitter {
}
write!(self.f, "{{").unwrap();
for (name, field) in fields {
write!(self.f, "\n.{} = ", name).unwrap();
write!(self.f, ".{} = ", name).unwrap();
self.emit_expr(field);
write!(self.f, ",\n").unwrap();
write!(self.f, ",").unwrap();
}
write!(self.f, "}}").unwrap();
}
Expand Down

0 comments on commit 52640db

Please sign in to comment.