If a global variable is initialized to 0, will it go to BSS?

后端 未结 3 1651
逝去的感伤
逝去的感伤 2020-12-08 07:35

All the initialized global/static variables will go to initialized data section. All the uninitialized global/static variables will go to uninitialed data secti

3条回答
  •  孤街浪徒
    2020-12-08 08:12

    The behavior is dependent upon the C implementation. It may end up in either .data or .bss, and to increase changes that it does not end up in .data taking redundant space up, it's better not to explicitly initialize it to 0, since it will be set to 0 anyway if the object is of static duration.

提交回复
热议问题