ERROR: do not initialise statics to false
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
ERROR: do not initialise statics to false的更多相关文章
- error: { "$err" : "not master and slaveOk=false", "code" : 13435 }
rsguo:SECONDARY> db.users.find();error: { "$err" : "not master and slaveOk=false&q ...
- 【GoLang】GoLang 官方 对 error 处理的意见
The Go Blog Errors are values 12 January 2015 A common point of discussion among Go programmers, esp ...
- 解决Eclipse启动Tomcat时报Error loading WebappClassLoader错误
最近新建了一个JSF项目(网上查到用Struts,Spring MVC也会如此),配置好以后用Eclipse启动Tomcat报了如下错误:严重: Error loading WebappClassLo ...
- MongoDb的“not master and slaveok=false”错误及解决方法,读写分离
首先这是正常的,因为SECONDARY是不允许读写的, 在写多读少的应用中,使用Replica Sets来实现读写分离.通过在连接时指定或者在主库指定slaveOk,由Secondary来分担读的压力 ...
- MongoDB的“not master and slaveok=false”错误解决
在客户端操作MongoDB时经常会如下错误: SECONDARY> show collections; Fri Jul :: uncaught exception: error: { } 原因是 ...
- iview组件 eslint校验出错 Parsing error: x-invalid-end-tag
如下: 解决: 在.eslintrc.js文件中加上: rules: { // allow async-await 'generator-star-spacing': 'off', // allow ...
- js里面return 和 return false的区别
js里面return 和 return false的区别 1.都可以终止执行当前方法: 2.如果方法A调用了方法B,则在方法A中使用return可以终止程序,但是在方法B中使用return则终止执行B ...
- return false 和 return true
常规用法 在普通函数中:return 语句终止函数的执行,并返回一个指定的值给函数调用者,一般会用一个变量接收这个返回值再进行其它处理.如果未指定返回值,则返回 undefined 其中,返回一个函数 ...
- 《Note --- Unreal --- MemPro (CONTINUE... ...)》
Mem pro 是一个主要集成内存泄露检测的工具,其具有自身的源码和GUI,在GUI中利用"Launch" button进行加载自己待检测的application,目前支持的平台为 ...
随机推荐
- delphi 更改DBGrid 颜色技巧
1.根据条件更改某一单元格的颜色 procedure TMainFrm.First_DGDrawColumnCell(Sender: TObject; const Rect: TRect; DataC ...
- matlab exist函数
函数作用:用于确定某变量或值是否存在. 调用格式: exist主要有两种形式,一个参数和两个参数的,作用都是用于确定某值是否存在:1. b = exist( a) 若 a 存在,则 b = 1: 否则 ...
- 【bzoj1036】[ZJOI2008]树的统计Count 树链剖分+线段树
题目描述 一棵树上有n个节点,编号分别为1到n,每个节点都有一个权值w.我们将以下面的形式来要求你对这棵树完成一些操作: I. CHANGE u t : 把结点u的权值改为t II. QMAX u v ...
- Python fileinput模块详解
Python的fileinput模块可以快速对一个或多个文件进行循环遍历. import fileinput for line in fileinput.input(): process(line) ...
- html的head内标签
ctrl+?:自动注释 ctrl+/: 注释多行,再按一次,取消注释的多行. 一,*********本地测试的方法:1-找到文件路径,直接浏览器打开:2-pycharm打开测试. 二,模板的解释: ...
- CentOS 磁盘阵列(raid10)
1.通过mdadm命令进行磁盘阵列部署 mdadm是multiple devices admin的简称,它是Linux下的一款标准的软件 RAID 管理工具 如果没有mdadm命令,通过yum安装一下 ...
- [洛谷P5174]圆点
题目大意:给你$R(R\leqslant10^{14})$,求:$$\sum\limits_{x\in\mathbb{Z}}\sum\limits_{y\in\mathbb{Z}}[x^2+y^2\l ...
- bzoj 3280: 小R的烦恼 (网络流)
和开发计划一样(数组开太小wa了好多次,然后为什么这么慢? type arr=record toward,next,cap,cost:longint; end; const maxm=; maxn=; ...
- 实验五 TCP传输及加解密
北京电子科技学院(BESTI) 实 验 报 告 课程:Java程序设计 班级:1353 姓名:陈巧然 ...
- Desert King 最小比率生成树 (好题)
Description David the Great has just become the king of a desert country. To win the respect of his ...