错误 - 无效* - 未知大小 [英] Error - void* - unknown size

查看:166
本文介绍了错误 - 无效* - 未知大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我从第三方获得此功能包含以下code,它并不在MS Visual Studio中编译10.我觉得有一个问题,铸件,但不知道如何解决这个问题。

 无效dump_ffmpeg_pad16(FILE *流,uint32_t的时间戳,无效*数据,
                   INT DATA_SIZE)
{
    unsigned int类型Z = 0;
    void *的结束=数据+ DATA_SIZE;
    而(数据<末){
        Z = *(无符号短*)的数据;
        FWRITE(((字符*)(安培; Z)),3,1,流);
        数据+ = 2;
    }
}

已责成在他们的帮助编译为C ++ code。感谢您的帮助。


解决方案

  void *的结束=数据+ DATA_SIZE;

应该是:

  void *的结束=((字符*)数据)+ DATA_SIZE;

添加到无效* 是一个GCC扩展。

This function which I received from a third party contains the following code which does not compile in MS Visual Studio 10. I think there is a casting problem but do not know how to fix this.

void dump_ffmpeg_pad16(FILE *stream, uint32_t timestamp, void *data,
                   int data_size)
{
    unsigned int z=0;
    void *end = data + data_size;
    while (data < end) {
        z = *(unsigned short*)data;
        fwrite(((char*)(&z)), 3, 1, stream);
        data += 2;
    }
}

It has been instructed in their help to compile as C++ code. Thanks for your help.

解决方案

void *end = data + data_size;

Should be:

void *end = ((char *) data) + data_size;

Adding to a void* is a GCC extension.

这篇关于错误 - 无效* - 未知大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆