码迷,mamicode.com
首页 > 其他好文 > 详细

libpcap 中调用ctime()时警告提示:

时间:2016-06-20 22:09:39      阅读:200      评论:0      收藏:0      [点我收藏+]

标签:

warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat=]  
 例如: printf("%s", ctime((const time_t *)&protocol_header.ts.tv_sec));

加上ctime的头文件<time.h>就可以解决。

理由:在64位的Linux 下,int是32位的,而指针(在这里是 char *)是64位的。问题应该就是出在这里!
 
  同样的问题在用inet_ntoa()时也容易出现!!

libpcap 中调用ctime()时警告提示:

标签:

原文地址:http://www.cnblogs.com/soyo/p/5601847.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!