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

解决warning: format ‘%x’ expects type ‘unsigned int’, but argument 2 has type ‘int *’

时间:2014-11-06 02:11:28      阅读:1093      评论:0      收藏:0      [点我收藏+]

标签:different   function   address   warning   压滤机   

[root@CC c]# gcc MemTest.c -o MemTest1 -Wall
MemTest.c: In function ‘main’:
MemTest.c:24: warning: format ‘%x’ expects type ‘unsigned int’, but argument 2 has type ‘int *’
MemTest.c:39: warning: format ‘%x’ expects type ‘unsigned int’, but argument 2 has type ‘int *’

MemTest.c:24: warning: cast from pointer to integer of different size
MemTest.c:39: warning: cast from pointer to integer of different size



代码中增加下面对应颜色的部分
int i, *intptr=NULL;
intptr = (int *)malloc(sizeof(int)*16);
printf("intptr address: 0x%x\n", (unsigned int)(long)intptr);

解决warning: format ‘%x’ expects type ‘unsigned int’, but argument 2 has type ‘int *’

标签:different   function   address   warning   压滤机   

原文地址:http://richmond.blog.51cto.com/1345557/1572733

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