其中一些可能是重复的,但我很抱歉。
假设我有这个struct
:
struct foo
{
int a;
int b;
int c;
};
1.如果struct foo
类型对象以具有自动存储持续时间且没有初始化器的方式声明,是否保证它的所有成员都将被强制初始化为零?
{
// other stuff
struct foo bar;
// other stuff
}
2.如果struct foo
类型对象以具有自动存储持续时间并带有一些初始化程序的方式声明,是否保证未显式初始化的成员将被强制初始化为零?
{
// other stuff
struct foo bar = {.a = 1};
// other stuff
}
3.如果struct foo
类型对象以具有自动存储持续时间的方式声明并使用复合文字表达式,是否保证未显式初始化的成员将被强制初始化为零?
{
// other stuff
func((struct foo){.a = 1});
// other stuff
}
非常感谢任何 C 标准参考!谢谢!