Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1204718
  • 博文数量: 185
  • 博客积分: 495
  • 博客等级: 下士
  • 技术积分: 1418
  • 用 户 组: 普通用户
  • 注册时间: 2012-09-02 15:12
个人简介

治肾虚不含糖,专注内核性能优化二十年。 https://github.com/KnightKu

文章分类

全部博文(185)

文章存档

2019年(1)

2018年(12)

2017年(5)

2016年(23)

2015年(1)

2014年(22)

2013年(82)

2012年(39)

分类: LINUX

2013-05-07 13:54:59

编译libconhash的时候出现了一些类型问题的警告:

conhash_util.c: In function ‘conhash_get_vnodes’:
conhash_util.c:31:2: warning: passing argument 1 of ‘util_rbtree_mid_travel’ discards ‘const’ qualifier from pointer target type [enabled by default]
util_rbtree.h:112:6: note: expected ‘struct util_rbtree_t *’ but argument is of type ‘const struct util_rbtree_t *’
gcc -I. -I.  -c conhash.c -o bin/conhash.o
conhash.c: In function ‘conhash_lookup’:
conhash.c:80:2: warning: passing argument 1 of ‘util_rbtree_lookup’ discards ‘const’ qualifier from pointer target type [enabled by default]
util_rbtree.h:74:21: note: expected ‘struct util_rbtree_t *’ but argument is of type ‘const struct util_rbtree_t *’

util_rbtree_mid_travel函数声明如下:
void util_rbtree_mid_travel(util_rbtree_t *rbtree, void(*opera)(util_rbtree_node_t *, void *), void *data);
调用时是如下形式的:
util_rbtree_mid_travel(&(conhash->vnode_tree), __get_vnodes, &vnodes);
因为&取址运算符的返回值是const的常指针,因此才出现了上面的警告。
修改函数util_rbtree_mid_travel的原先如下,即第一个参数为常指针:
void util_rbtree_mid_travel(const util_rbtree_t *rbtree, void(*opera)(util_rbtree_node_t *, void *), void *data);

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