Skip to content

Commit

Permalink
Apply cfg to struct literal
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowone committed May 17, 2024
1 parent e43c2bd commit 37627ba
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/bindgen/language_backend/clike.rs
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,11 @@ impl LanguageBackend for CLikeLanguageBackend<'_> {
}
is_first_field = false;

let condition = lit.cfg.to_condition(self.config);
if condition.is_some() {
out.new_line();
}
condition.write_before(self.config, out);
if self.config.language == Language::Cxx {
// TODO: Some C++ versions (c++20?) now support designated
// initializers, consider generating them.
Expand All @@ -931,6 +936,10 @@ impl LanguageBackend for CLikeLanguageBackend<'_> {
write!(out, ".{} = ", ordered_key);
}
self.write_literal(out, &lit.value);
condition.write_after(self.config, out);
if condition.is_some() {
out.new_line();
}
}
}
write!(out, " }}");
Expand Down

0 comments on commit 37627ba

Please sign in to comment.