<分区>
例如
static char all_data;
没有初始化它的值。默认值是多少?还是未定义的行为?
我在我的 gcc-4.6 上试过,答案是 0。
谢谢。
标签 c
<分区>
例如
static char all_data;
没有初始化它的值。默认值是多少?还是未定义的行为?
我在我的 gcc-4.6 上试过,答案是 0。
谢谢。
最佳答案
根据 C99:
If an object that has static storage duration is not initialized explicitly,
then:
— if it has pointer type, it is initialized to a null pointer;
— if it has arithmetic type, it is initialized to (positive or unsigned) zero;
— if it is an aggregate, every member is initialized (recursively) according to these rules;
— if it is a union, the first named member is initialized (recursively) according to these
rules.
关于c - 在 C 中, "static char"类型的默认值是多少,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20852243/