【发布时间】:2021-04-27 16:15:06
【问题描述】:
顾名思义,它会在缺少字段初始值设定项时触发。但它没有触发以下代码的任何警告。
#include <stdio.h>
struct test {
int a, b, c;
};
void func(struct test test) {
printf("%d, %d, %d\n", test.a, test.b, test.c);
}
int main() {
func((struct test) {12, .a = 1, 12, .a = 13, .b = 13});
return 0;
}
当我运行gcc test.c -Wmissing-field-initializers 时,它编译时没有任何警告。它打印出13, 13, 0。这是-Wmissing-field-initializers 的默认行为吗?
【问题讨论】:
标签: c gcc gcc-warning