We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
[0; N]
1 parent 68de84c commit a56b3eeCopy full SHA for a56b3ee
c2rust-transpile/src/translator/literals.rs
@@ -190,6 +190,14 @@ impl<'c> Translation<'c> {
190
if is_string {
191
let v = ids.first().unwrap();
192
self.convert_expr(ctx.used(), *v)
193
+ } else if ids.len() == 0 && ty.is_integral_type() || ty.is_floating_type() {
194
+ // this was likely a C array of the form `int x[16] = {}`,
195
+ // we'll emit that as [0; 16].
196
+ let len = mk().lit_expr(mk().int_unsuffixed_lit(n as u128));
197
+ self.implicit_default_expr(ty, ctx.is_static)?
198
+ .and_then(|default_value| {
199
+ Ok(WithStmts::new_val(mk().repeat_expr(default_value, len)))
200
+ })
201
} else {
202
Ok(ids
203
.iter()
0 commit comments