问题描述
我需要一个线索。我得到一个增量无效左值来自gcc
4.1.2在这一行...
sum + = *((unsigned short *)iphp)++;
....但我不知道问题是什么。 gcc 3.4.3也没有打扰它。
机器细节:
$ uname -a
Linux tmxnw-fc6 2.6.22.9-61.fc6#1 SMP Thu Sep 27 18:48:03 EDT 2007
i686 i686 i386 GNU / Linux
$ gcc --version
gcc(GCC)4.1.2 20070626(Red Hat 4.1.2-13)
I need a clue. I''m getting an "invalid lvalue in increment" from gcc
4.1.2 on this line...
sum += *((unsigned short *)iphp)++ ;
....but I don''t see what the problem is. gcc 3.4.3 isn''t bother by
it, either.
Machine specifics:
$ uname -a
Linux tmxnw-fc6 2.6.22.9-61.fc6 #1 SMP Thu Sep 27 18:48:03 EDT 2007
i686 i686 i386 GNU/Linux
$ gcc --version
gcc (GCC) 4.1.2 20070626 (Red Hat 4.1.2-13)
推荐答案
(无符号短*)iphp不是左值。你想在哪里存储
(unsigned short *)iphp + 1?据推测,您希望将其存储在iphp中。如果你想要那个,那就写下来吧。
sum + = *((unsigned short *)iphp);
iphp =((unsigned short *)iphp)+ 1;
你可以认为它类似于
int i;
( i + 1)= -1;
(双倍)i = 1.5;
(unsigned short *)iphp is not an lvalue. Where do you want to store
(unsigned short *)iphp + 1? Presumably, you want to store it in iphp. If
you want that, write that.
sum += *((unsigned short *)iphp);
iphp = ((unsigned short *)iphp) + 1;
You can consider it similar to
int i;
(i + 1) = -1;
(double) i = 1.5;
这篇关于gcc:这有什么不合法的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!