pointer targets in passing argument n of xxx differ in signedness

GCC编译出现警告

test_hashtable.c:52: warning: pointer targets in passing argument 3 of ‘hash_table_insert’ differ in signedness
test_hashtable.c:61: warning: pointer targets in passing argument 2 of ‘hash_table_lookup_key’ differ in signedness
test_hashtable.c:77: warning: pointer targets in passing argument 1 of ‘strlen’ differ in signedness

找到一个类似的问题

http://www.cnblogs.com/yuphone/archive/2010/11/26/1888286.html

它的与此很类似。"Clear" 默认为 const char * ,而要求传递的 u8* ——根据名称来推测u8 应该转义为unsigned char

即传递的应该为 unsigned char *类型的指针。虽然两者在内存上是等价的,但是"differ in signedness",所以报出警告信息。

解决办法是显示的强制类型转换。

还有种思路是显示的告诉编译器,忽略这种警告。

posted @ 2011-04-07 11:26  westfly  阅读(5535)  评论(0编辑  收藏  举报