linux make:消除Warning

1:warning: comparison between signed and unsigned integer expressions

解决方法:强制类型转换 前面都加上(int),进行强制类型转换


   if (key == NULL || (int)strlen(key) >(int)I_LIMITED_SIMPLE || strlen(key) < 1)
   // if (key == NULL || strlen(key) > I_LIMITED_SIMPLE || strlen(key) < 1)


2: warning:  ‘unsigned int sdk_req::m_nBufferLength’


添加语句

#define UNUSED_VAR     __attribute__ ((unused))

for any variable just use the above macro before its type for example:

UNUSED_VAR int a = 2;
如:在原来变量前面添加UNUSED_VAR,即可
static const char*              V_REQUEST_STATE_END =           "END";
static const char*              V_REQUEST_STATE_DOING =         "DOING";
UNUSED_VAR static const char*           V_REQUEST_STATE_IDLE =          "IDLE";
UNUSED_VAR static const char*           V_REQUEST_STATE_RELEASE =       "RELEASE";


UNUSED_VAR static const char*           V_REQUEST_CONNECT_KEEP =        "Keep-Alive";
UNUSED_VAR static const char*           V_REQUEST_CONNECT_CLOSE =       "Close";


3: warning: suggest parentheses around assignment used as truth value

解决方法:在if判断语句中添加个()


 if ((tmpLen = atoi(m_reqHttpRequest.GetHttpHeader(H_CONTENT_LENGTH).c_str())) > 0)
   // if (tmpLen = atoi(m_reqHttpRequest.GetHttpHeader(H_CONTENT_LENGTH).c_str()) > 0)


4:

../../api/libusc.cpp:662: warning: deprecated conversion from string constant to ‘char*’
../../api/libusc.cpp:664: warning: deprecated conversion from string constant to ‘char*’
../../api/libusc.cpp:666: warning: deprecated conversion from string constant to ‘char*’





其中 "false" 前面添加的(char*) 就是解决方法


5:

Warning: 'typedef' was ignored in this declaration

把 typedef 去掉。。


6:

../../../jni/sdk/sdk_http.h:19: warning: ‘sdk_http::m_nTimeout’ will be initialized after
../../../jni/sdk/sdk_http.h:18: warning:   ‘ghttp_request* sdk_http::m_pRequest’

../../../jni/sdk/sdk_http.cpp:36: warning:   when initialized here

解决方法:初始化顺序引起的, 需要按照 构造函数定义的顺序,进行初始化

初始化列表的顺序应该是按照你成员声明顺序初始化。


7:warning: array subscript has type ‘char’

主要错误地方是:这个warning是说,数组的下标被定义成char型了,由于char型有可能是负数,因此会产生难以 预料的错误。

 

修改:使用无符号类型替代有符号类型。

解决方法:加入unsigned int 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值