Question about git commit rule

I git commit a patch,

The patch has a "static int xxxxxxxxxxxxxxxxxxxxxxxxxx = 0;"

It show error messge "ERROR: do not initialise statics to false"

Why can't initialize a static variable = false in function ?

All static variable that is uninitialize are moved to BSS section.

Linux initialize these static variable to zero in BSS section.

So just write "static variable" in function.

Example :

incorrect.c

#include <stdio.h>
int main()
{
static int xxxxxxxxxxxxxxxxxxxxxxxxxx = 0;
static int aaaaaaaaaaaaaaaaaaaaaaaaaa = 0; printf("exit \n");
}

correct.c

#include <stdio.h>
int main()
{
static int xxxxxxxxxxxxxxxxxxxxxxxxxx;
static int aaaaaaaaaaaaaaaaaaaaaaaaaa; printf("exit \n");
}
gcc -o correct correct.c
objdump -x correct | grep bss
 24 .bss          00000010  0000000000601040  0000000000601040  00001040  2**2
0000000000601040 l d .bss 0000000000000000 .bss
0000000000601040 l O .bss 0000000000000001 completed.7262
0000000000601044 l O .bss 0000000000000004 aaaaaaaaaaaaaaaaaaaaaaaaaa.2200
0000000000601048 l O .bss 0000000000000004 xxxxxxxxxxxxxxxxxxxxxxxxxx.2199
0000000000601050 g .bss 0000000000000000 _end
0000000000601040 g .bss 0000000000000000 __bss_start

Reference:

http://www.jollen.org/blog/2007/01/no-zero-initialized-in-bss.htmlbvg

最新文章

  1. RMAN-06023: no backup or copy of datafile 1 found to restore
  2. Linux 下配置php开发环境
  3. IOS9 Swift
  4. [20140711] SQL Server page还原
  5. C++ 构造函数放置默认转换explicit关键字(2)
  6. SQL Developer不能删除和复制及部分键失效问题
  7. Windows下配置使用WinPcap
  8. bzoj1412: [ZJOI2009]狼和羊的故事
  9. Notepad++强大的代码补全和代码提示功能的方法
  10. TreeList
  11. Android中Drawable分类汇总(上)
  12. Spring4 AOP详解
  13. TypeError:Error #1009
  14. 谈谈使用Redis缓存时批量删除的几种实现
  15. C#语法——消息,MVVM的核心技术。
  16. Ubuntu 自动选择最快的镜像源
  17. 微信小程序多层嵌套循环,二级数组遍历
  18. 如何在VMware中安装Linux系统
  19. delphi c#语法转换
  20. css选择器,样式表导入

热门文章

  1. 第33天:封装自己的class类
  2. RT-thread 设备驱动组件之PIN设备
  3. 未找到与约束ContractName Microsoft.VisualStudio.Text.ITextDocumentFactoryService...匹配的导出
  4. 具体数学数论章-----致敬Kunth
  5. [洛谷P5107]能量采集
  6. [洛谷P4070][SDOI2016]生成魔咒
  7. BZOJ2553 [BeiJing2011]禁忌 【AC自动机 + dp + 矩乘优化】
  8. bzoj1867: [Noi1999]钉子和小球(DP)
  9. [CQOI2011]放棋子
  10. Linux下 ps -ef 和 ps aux 的区别及格式详解