ads1.2编译vc程序,出现implicit cast of pointer to non-equal pointer

lius1984 2009-04-21 11:07:31
我把程序从vc9移植到ads1.2上,有很多错误都是由于编译器不支持指针类型的隐式转换造成的。这个问题我是百思不得其解,不知道应该怎么强制转换...还请高手指教...

出错行:init_put_byte(*s, buffer, buffer_size,(h->flags & URL_WRONLY || h->flags & URL_RDWR), h,url_read, url_write, url_seek)

ERROR:
Error : C3028E: <argument 6 to 'init_put_byte'>: implicit cast of pointer to non-equal pointer
aviobuf.c line 556
Error : C3028E: <argument 7 to 'init_put_byte'>: implicit cast of pointer to non-equal pointer
aviobuf.c line 556
Error : C3028E: <argument 8 to 'init_put_byte'>: implicit cast of pointer to non-equal pointer

函数定义:
int init_put_byte(ByteIOContext *s,unsigned char *buffer,int buffer_size,int write_flag,void *opaque,
int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
int64_t (*seek)(void *opaque, int64_t offset, int whence))

...全文
3438 10 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
ceasar_2011 2012-04-07
  • 打赏
  • 举报
回复 1
查了好久,不是楼主说的这个原因
是因为你的ads编译选项没有选择

debugrel setting -> arm c compiler -> error -> implicit pointer c不要勾选就可以了
具体意义可以查查编译器相关手册
qwedcazsx 2011-05-25
  • 打赏
  • 举报
回复
使用(void *)强制转换就好了。
xujinhui197 2009-10-20
  • 打赏
  • 举报
回复
I Have the same problem
bknight24 2009-07-16
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 hairetz 的回复:]
先把格式转为void *,然后再转成你需要的格式.
[/Quote]

我也出现了楼主的问题,这样就能编译了。为什么呢?
ltc_mouse 2009-04-21
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 lius1984 的回复:]
int url_read(URLContext *h, unsigned char *buf, int size);
int url_write(URLContext *h, unsigned char *buf, int size);
int64_t url_seek(URLContext *h, int64_t pos, int whence);

应该怎样强制转化呢? 谢谢.
[/Quote]
这些函数参数个数,参数类型和返回值,与目标函数是“兼容”(说法也许不准确,参考...)的,即调用不会引起错误,可以强转,试试我3楼提供的...
lius1984 2009-04-21
  • 打赏
  • 举报
回复
int url_read(URLContext *h, unsigned char *buf, int size);
int url_write(URLContext *h, unsigned char *buf, int size);
int64_t url_seek(URLContext *h, int64_t pos, int whence);

应该怎样强制转化呢? 谢谢.

ltc_mouse 2009-04-21
  • 打赏
  • 举报
回复
用一下typedef,然后就可以像普通类型转换那么使用了~
typedef int (*read_packet_func_t)(void *opaque, uint8_t *buf, int buf_size);
typedef int (*write_packet_func_t)(void *opaque, uint8_t *buf, int buf_size);
typedef int int64_t (*seek_func_t)(void *opaque, int64_t offset, int whence);

init_put_byte(*s, buffer, buffer_size,(h->flags & URL_WRONLY || h->flags & URL_RDWR), h,
(read_packet_func_t)url_read, (write_packet_func_t)url_write, (seek_func_t)url_seek);

不过对于函数指针参数,要注意的是到底能不能转换,有些强制转换可能引入错误...
能否把url_read,url_write,url_seek的原型也贴出来看看?
  • 打赏
  • 举报
回复
先把格式转为void *,然后再转成你需要的格式.
jame2001 2009-04-21
  • 打赏
  • 举报
回复
url_read 宣告的不符合 init_put_byte 的參數..
列出 url_read, url_write, url_seek 的宣告來看看..
應該是function pointer 格式

70,027

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧