c++ - 编译 mpeg4ip 会出现解引用类型双关指针错误

标签 c++ c

我试图在 Linux 机器(Redhat 9)上编译 mpeg4ip,但遇到很多错误,因为它显然不再受支持。这是我收到的错误:

make[5]: Entering directory `/home/ec2-user/mpeg4ip-1.5.0.1/lib/rtp'
if /bin/sh ./libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I.    -DDEBUG -Wall -Werror -g -O2 -Wall -Werror -W  -Wmissing-prototypes -Wmissing-declarations -Wbad-function-cast -Wwrite-strings -Wformat=2 -MT rijndael-alg-fst.lo -MD -MP -MF ".deps/rijndael-alg-fst.Tpo" -c -o rijndael-alg-fst.lo rijndael-alg-fst.c; \
then mv -f ".deps/rijndael-alg-fst.Tpo" ".deps/rijndael-alg-fst.Plo"; else rm -f ".deps/rijndael-alg-fst.Tpo"; exit 1; fi
 gcc -DHAVE_CONFIG_H -I. -I. -I. -DDEBUG -Wall -Werror -g -O2 -Wall -Werror -W -Wmissing-prototypes -Wmissing-declarations -Wbad-function-cast -Wwrite-strings -Wformat=2 -MT rijndael-alg-fst.lo -MD -MP -MF .deps/rijndael-alg-fst.Tpo -c rijndael-alg-fst.c  -fPIC -DPIC -o .libs/rijndael-alg-fst.o
cc1: warnings being treated as errors
rijndael-alg-fst.c: In function 'rijndaelEncrypt':
rijndael-alg-fst.c:126: error: dereferencing type-punned pointer will break strict-aliasing rules
rijndael-alg-fst.c:147: error: dereferencing type-punned pointer will break strict-aliasing rules
rijndael-alg-fst.c:170: error: dereferencing type-punned pointer will break strict-aliasing rules
rijndael-alg-fst.c: In function 'rijndaelDecrypt':
rijndael-alg-fst.c:274: error: dereferencing type-punned pointer will break strict-aliasing rules
rijndael-alg-fst.c:296: error: dereferencing type-punned pointer will break strict-aliasing rules
rijndael-alg-fst.c:318: error: dereferencing type-punned pointer will break strict-aliasing rules
make[5]: *** [rijndael-alg-fst.lo] Error 1
make[5]: Leaving directory `/home/ec2-user/mpeg4ip-1.5.0.1/lib/rtp'
make[4]: *** [all-recursive] Error 1
make[4]: Leaving directory `/home/ec2-user/mpeg4ip-1.5.0.1/lib/rtp'
make[3]: *** [all] Error 2
make[3]: Leaving directory `/home/ec2-user/mpeg4ip-1.5.0.1/lib/rtp'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/home/ec2-user/mpeg4ip-1.5.0.1/lib'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/ec2-user/mpeg4ip-1.5.0.1'
make: *** [all] Error 2

违规方法(或至少其中一种)是:

int rijndaelEncrypt(word8 a[16], word8 b[16], word8 rk[MAXROUNDS+1][4][4], int ROUNDS) {
    int r;
    word8 temp[4][4];

*((word32*)temp[0]) = *((word32*)(a   )) ^ *((word32*)rk[0][0]);
*((word32*)temp[1]) = *((word32*)(a+ 4)) ^ *((word32*)rk[0][1]);
*((word32*)temp[2]) = *((word32*)(a+ 8)) ^ *((word32*)rk[0][2]);
*((word32*)temp[3]) = *((word32*)(a+12)) ^ *((word32*)rk[0][3]);
*((word32*)(b    )) = *((word32*)T1[temp[0][0]])
                                            ^ *((word32*)T2[temp[1][1]])
                                            ^ *((word32*)T3[temp[2][2]])
                                            ^ *((word32*)T4[temp[3][3]]);
*((word32*)(b + 4)) = *((word32*)T1[temp[1][0]])
                                            ^ *((word32*)T2[temp[2][1]])
                                            ^ *((word32*)T3[temp[3][2]])
                                            ^ *((word32*)T4[temp[0][3]]);
*((word32*)(b + 8)) = *((word32*)T1[temp[2][0]])
                                            ^ *((word32*)T2[temp[3][1]])
                                            ^ *((word32*)T3[temp[0][2]])
                                            ^ *((word32*)T4[temp[1][3]]);
*((word32*)(b +12)) = *((word32*)T1[temp[3][0]])
                                            ^ *((word32*)T2[temp[0][1]])
                                            ^ *((word32*)T3[temp[1][2]])
                                            ^ *((word32*)T4[temp[2][3]]);
    for (r = 1; r < ROUNDS-1; r++) {
            *((word32*)temp[0]) = *((word32*)(b   )) ^ *((word32*)rk[r][0]);
            *((word32*)temp[1]) = *((word32*)(b+ 4)) ^ *((word32*)rk[r][1]);
            *((word32*)temp[2]) = *((word32*)(b+ 8)) ^ *((word32*)rk[r][2]);
            *((word32*)temp[3]) = *((word32*)(b+12)) ^ *((word32*)rk[r][3]);

            *((word32*)(b    )) = *((word32*)T1[temp[0][0]])
                                                    ^ *((word32*)T2[temp[1][1]])
                                                    ^ *((word32*)T3[temp[2][2]])
                                                    ^ *((word32*)T4[temp[3][3]]);
            *((word32*)(b + 4)) = *((word32*)T1[temp[1][0]])
                                                    ^ *((word32*)T2[temp[2][1]])
                                                    ^ *((word32*)T3[temp[3][2]])
                                                    ^ *((word32*)T4[temp[0][3]]);
            *((word32*)(b + 8)) = *((word32*)T1[temp[2][0]])
                                                    ^ *((word32*)T2[temp[3][1]])
                                                    ^ *((word32*)T3[temp[0][2]])
                                                    ^ *((word32*)T4[temp[1][3]]);
            *((word32*)(b +12)) = *((word32*)T1[temp[3][0]])
                                                    ^ *((word32*)T2[temp[0][1]])
                                                    ^ *((word32*)T3[temp[1][2]])
                                                    ^ *((word32*)T4[temp[2][3]]);
    }
    /* last round is special */
    *((word32*)temp[0]) = *((word32*)(b   )) ^ *((word32*)rk[ROUNDS-1][0]);
    *((word32*)temp[1]) = *((word32*)(b+ 4)) ^ *((word32*)rk[ROUNDS-1][1]);
    *((word32*)temp[2]) = *((word32*)(b+ 8)) ^ *((word32*)rk[ROUNDS-1][2]);
    *((word32*)temp[3]) = *((word32*)(b+12)) ^ *((word32*)rk[ROUNDS-1][3]);
    b[ 0] = T1[temp[0][0]][1];
    b[ 1] = T1[temp[1][1]][1];
    b[ 2] = T1[temp[2][2]][1];
    b[ 3] = T1[temp[3][3]][1];
    b[ 4] = T1[temp[1][0]][1];
    b[ 5] = T1[temp[2][1]][1];
    b[ 6] = T1[temp[3][2]][1];
    b[ 7] = T1[temp[0][3]][1];
    b[ 8] = T1[temp[2][0]][1];
    b[ 9] = T1[temp[3][1]][1];
    b[10] = T1[temp[0][2]][1];
    b[11] = T1[temp[1][3]][1];
    b[12] = T1[temp[3][0]][1];
    b[13] = T1[temp[0][1]][1];
    b[14] = T1[temp[1][2]][1];
    b[15] = T1[temp[2][3]][1];
    *((word32*)(b   )) ^= *((word32*)rk[ROUNDS][0]);
    *((word32*)(b+ 4)) ^= *((word32*)rk[ROUNDS][1]);
    *((word32*)(b+ 8)) ^= *((word32*)rk[ROUNDS][2]);
    *((word32*)(b+12)) ^= *((word32*)rk[ROUNDS][3]);

    return 0;
}

有人可以建议我如何解决这个问题吗?我在网上找到了该文件的较新版本(版本 3),但是当我尝试实现该文件时,我遇到的错误比您所能想象的还要多。提前致谢。

最佳答案

下载最新的源代码(对我来说是 mpeg4ip-1.6.1 版本)

ftp://ftp.netbsd.org/pub/pkgsrc/distfiles/mpeg4ip-1.6.1.tar.gz

(如果出现错误,请注释 include/mpeg4ip.h 的第 126 行)

make and make install 

关于c++ - 编译 mpeg4ip 会出现解引用类型双关指针错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19699365/

相关文章:

c++ - pragmas simd 和 ivdep vector 之间的区别总是?

c - 在 rhel 6.1 上安装 gcc

c - 尝试将 "byte"信息存储到 %x 时发生位扩展

Android - 如何在 Windows 上构建 native 库并在 Android NDK 中使用它

c++ - Visual Studio Express 中禁用的工具箱

c++ - 结构数组

c++ - 日期和当前日期之间的差异

c++ - 用 gcc 编译 std::regex_iterator

c++ - 我们可以从父进程中读取子进程的环境变量吗

c - Keil uVision v.5.12.0.0 中的构建问题