cgen: fix optional struct declarations for empty structs (#13970)

pull/13972/head
yuyi 2022-04-08 19:51:37 +08:00 committed by GitHub
parent 45a427e68b
commit 617608b23d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 4 deletions

View File

@ -1,9 +1,7 @@
import json
import os
struct DbConfig {
foo int
}
struct DbConfig {}
fn test_json_decode_with_optional_arg() {
if ret := print_info() {

View File

@ -972,7 +972,7 @@ fn (g Gen) optional_type_text(styp string, base string) string {
ret := 'struct $styp {
byte state;
IError err;
byte data[sizeof($size)];
byte data[sizeof($size) > 0 ? sizeof($size) : 1];
}'
return ret
}