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,目前支持的平台为 ...
随机推荐
- [Leetcode] pascals triangle ii 帕斯卡三角
Given an index k, return the k th row of the Pascal's triangle. For example, given k = 3,Return[1,3, ...
- [Leetcode] single number ii 找单个数
Given an array of integers, every element appears three times except for one. Find that single one. ...
- warning: React does not recognize the xxx prop on a DOM element
这是React不能识别dom元素上的非标准attribute报出的警告,最终的渲染结果中React会移除这些非标准的attribute. 通常{...this.props}和cloneElement( ...
- NDK plugin来构建JNI项目(相对于手动构建)
http://blog.csdn.net/codezjx/article/details/8879670 1.添加ndk环境支持 Android Tools -> Add Native Supp ...
- 阐述ArrayList、Vector、LinkedList的存储性能和特性?
ArrayList 和Vector他们底层的实现都是一样的,都是使用数组方式存储数据,此数组元素数大于实际存储的数据以便增加和插入元素,它们都允许直接按序号索引元素,但是插入元素要涉及数组元素移动等内 ...
- [ 转载]Tomcat7 catalina.out 日志分割
http://m.blog.csdn.net/blog/mark_qi/8864644 最近由于工作需要,tomcat 的catalina.out文件的不断扩大,导致系统磁盘空间边变小,而且管理也难于 ...
- lnmp环境不支持require 解决方法
lnmp环境配置: 3处改动地方---->排查过程: 从phpinfo.php中查找php.ini-----所在位置 /usr/local/php/etc/php.ini 1.display_e ...
- jq 正则
if(_each_this_type_name == 'post_num'){ var patrn = /^[a-zA-Z0-9]{3,12}$/; if(!patrn.test(_each_this ...
- jq 数组定义,拼接~~~push应用
var radio_checked_array = []; $("input[type='radio']").each(function(){ if($(this).attr('c ...
- Elastic Search操作入门
前言 Elastic Search是基于Lucene这个非常成熟的索引方案,另加上一些分布式的实现:集群,sharding,replication等.具体可以参考我同事写的文章. 本文主要介绍ES入门 ...