ads1.2编译vc程序,出现implicit cast of pointer to non-equal pointer,该如何处理
ads1.2编译vc程序,出现implicit cast of pointer to non-equal pointer
我把程序从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))
------解决方案--------------------
url_read 宣告的不符合 init_put_byte 的參數..
列出 url_read, url_write, url_seek 的宣告來看看..
應該是function pointer 格式
------解决方案--------------------
先把格式转为void *,然后再转成你需要的格式.
------解决方案--------------------
用一下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的原型也贴出来看看?
我把程序从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))
------解决方案--------------------
url_read 宣告的不符合 init_put_byte 的參數..
列出 url_read, url_write, url_seek 的宣告來看看..
應該是function pointer 格式
------解决方案--------------------
先把格式转为void *,然后再转成你需要的格式.
------解决方案--------------------
用一下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的原型也贴出来看看?