Chinaunix首页 | 论坛 | 博客
  • 博客访问: 185786
  • 博文数量: 9
  • 博客积分: 1722
  • 博客等级: 上尉
  • 技术积分: 225
  • 用 户 组: 普通用户
  • 注册时间: 2006-05-09 11:13
文章分类
文章存档

2012年(1)

2011年(5)

2010年(3)

分类: C/C++

2010-12-26 11:05:42

最近写程序要用到strcasestr, 正好有现成的函数,也没必要自已实现一个!
 
可是最终到编译阶段,老是报编译警告!warning: assignment makes pointer from integer without a cast
 
我一般很少不去理会警告,能去掉,能解决的,肯定要解决,因为警告存在,说明你的程序还是有一些容易出错的地方!
 
看了man手册,如果用strcasestr,要定义这个宏 #define _GNU_SOURCE
于是我在头这块写成这样,本以为只对string.h定义宏就可以了
 

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <iconv.h>

#define _GNU_SOURCE
#include <string.h>
.....
#undef _GNU_SOURCE

警告依然存在,于是我上网查了些相关的资料,都没大写明白怎么回事,只看到有关一个贴子说过宏的顺序不能写反,我应该没写反,我放在了string.h的上面呀

 

于是我反复的试,终于写成下面这样,警告去除!


 

#define _GNU_SOURCE
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <iconv.h>
#include <string.h>

......
#undef _GNU_SOURCE


阅读(3873) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~