【发布时间】:2011-09-06 23:05:05
【问题描述】:
我正在阅读nginx的源代码,发现它没有初始化很多数值变量,包括ngx_int_t ngx_last_process;,这里ngx_int_t定义为long int
#if 0
ngx_last_process = 0;
#endif
所以这里@Igor Sysoev 认为没有必要进行初始化?
但在程序中它假设默认值为0:
for (s = 0; s < ngx_last_process; s++) {
if (ngx_processes[s].pid == -1) {
break;
}
}
是否保证未初始化的变量在 c 中将具有 0 值?
【问题讨论】:
标签: c default-value initialization