c - 在 C 中, "static char"类型的默认值是多少

标签 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/

相关文章:

c - 将字符类型转换为整数类型是否安全

c - 当传递给 C 中的函数时丢失 char**array 的内容

c - 使用execv在C中拆分文件

c - 如何与玩家和 AI 交替移动

c - 将带有 void 指针参数的函数指针传递给函数

c - 如何为 FFmpeg 库创建函数以将帧编码为任何(可能的)格式?

c++ - Size Class 在 OpenCV 的源代码中的哪个位置?

无法在 Eclipse 中使用 gcc -shared 找到库来构建 dll

c++ - 以零开头的数字有什么特别之处?

c++ - 嵌入式系统中固有、内联、外部的区别?