在 GCC 中我得到以下错误:
aes.c: In function ‘copy_block’:
aes.c:278: error: lvalue required as increment operand
aes.c:278: error: lvalue required as increment operand
这是一段代码:
static void copy_block( void * d, void *s, uint_8t nn )
{
while( nn-- )
*((uint_8t*)d)++ = *((uint_8t*)s)++;
}
我试图将其更改为可编译版本,但不幸的是,作为一名 Java 程序员,我不清楚这里到底发生了什么。
也许有人知道我如何更改它在 GCC 中可编译的源代码,或者有人知道这里发生的详细情况。对我来说,左手值的取消引用似乎很奇怪,但不知何故,它似乎在 Visual C++ 中完美地工作。
这是一个小型遗留程序,我必须将其移植到 Linux 机器上。
提前感谢您的帮助。
最佳答案
试试这个:
#include <string.h>
static void copy_block( void * d, void *s, uint_8t nn ) {
memcpy(d, s, (size_t)nn);
}
那里做的不好。
关于无法理解 C 源代码,它不能在 GCC 中编译,但在 Visual C++ 中编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4850114/