error: invalid lvalue in increment

error: invalid lvalue in increment

Post by Florian Xa » Mon, 15 May 2006 18:53:11


Hi!

With new compiler I get many of this errors. Any chance to supress it? I
don't want to rewrite a hole library.

thanks
Flo
--
Florian Xaver < http://www.yqcomputer.com/ >

Dr-DOS Wiki < http://www.yqcomputer.com/ >
SWORD - a nice GUI library for DOS/DJGPP
< http://www.yqcomputer.com/ >
 
 
 

error: invalid lvalue in increment

Post by CBFalcone » Mon, 15 May 2006 19:46:59


The problem is your #define in line 42. gcc 8.03 is very
particular.

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: < http://www.yqcomputer.com/ ;
Also see < http://www.yqcomputer.com/ ;

 
 
 

error: invalid lvalue in increment

Post by Florian Xa » Mon, 15 May 2006 19:58:20

What is wrong?

...
(l_text)d += 1;
*d = GetKey(App) & 0xFF;
...

thanks
flo
--
Florian Xaver < http://www.yqcomputer.com/ >

Dr-DOS Wiki < http://www.yqcomputer.com/ >
SWORD - a nice GUI library for DOS/DJGPP
< http://www.yqcomputer.com/ >
 
 
 

error: invalid lvalue in increment

Post by alex bodna » Mon, 15 May 2006 21:24:46

the cast transforms a lvalue into a rvalue
 
 
 

error: invalid lvalue in increment

Post by Rod Pember » Wed, 17 May 2006 09:15:10


The behavior was deprecated. You can no longer cast lvalues in GCC.

You might unrolling the assignment, so the cast is an rvalue, like one of
these:

d=(pointertypeofd *)((l_text)d+1);

d=(typeofd)((l_text)d+1);

where "pointertypeofd" or "typeofd" is the proper cast needed for the
declared type of d...


From "GCC 3.4 Release Series Changes, New Features, and Fixes",
"The cast-as-lvalue extension has been removed for C++ and deprecated for C
and Objective-C. In particular, code like this:
int i;
(char) i = 5;

or this:

char *p;
((int *) p)++;

is no longer accepted for C++ and will not be accepted for C and Objective-C
in a future version."


Rod Pemberton
 
 
 

error: invalid lvalue in increment

Post by A. Wi » Wed, 17 May 2006 11:54:48


The trick is not to cast the variable itself,
but its address. This compiles without as
much as a warning:

main()
{
unsigned char c;

*(long long*)&c = 123456;

return 0;
}

People in love with the sound of their
typing ("strong typing"?) would probably
use "int main(void)".

-aw
 
 
 

error: invalid lvalue in increment

Post by Florian Xa » Sat, 20 May 2006 01:53:24


Thank you very much!!!

Bye
Flo






--
Florian Xaver < http://www.yqcomputer.com/ >

Dr-DOS Wiki < http://www.yqcomputer.com/ >
SWORD - a nice GUI library for DOS/DJGPP
< http://www.yqcomputer.com/ >
 
 
 

error: invalid lvalue in increment

Post by Robert Rie » Thu, 07 Jun 2007 17:28:43

Hi!

Why do I get "error: invalid lvalue in increment" at line "*(((unsigned
short *)address)++) = value;" with GCC 4.1.2? I already googled around,
but didn't find a `good' solution. Some work around, some recommend GCC
3.4.4, some talk about patching GCC.

***
static void rle_tga_read (unsigned char *address, int w, int type,
PACKFILE *f)
{
unsigned char value;
int count, g;
int c = 0;

do {
count = pack_getc(f);
if (count & 0x80) {
count = (count & 0x7F) + 1;
c += count;
value = pack_getc(f);
while (count--) {
if (type == 1)
*(address++) = value;
else
*(((unsigned short *)address)++) = value;
}
}
...
***

Taken from http://www.yqcomputer.com/

--
Robert Riebisch
Bitte NUR in der Newsgroup antworten!
Please reply to the Newsgroup ONLY!
 
 
 

error: invalid lvalue in increment

Post by DJ Delori » Thu, 07 Jun 2007 21:11:30


GCC no longer allows casts on the left side. You'll have to cast it
to an unsigned short * variable, use that variable to store and
increment, then cast that variable back to address.

a1 = (unsigned short *) address;
*a1++ = value;
address = (unsigned char) value;

GCC should optimize all the moves away and give you the original
opcodes.
 
 
 

error: invalid lvalue in increment

Post by Robert Rie » Thu, 07 Jun 2007 22:08:53


Why? ;-)


OK, thanks! :-)

--
Robert Riebisch
Bitte NUR in der Newsgroup antworten!
Please reply to the Newsgroup ONLY!
 
 
 

error: invalid lvalue in increment

Post by DJ Delori » Fri, 08 Jun 2007 00:34:02


The C language does not permit it, and gcc is becoming more strict
about following the C spec.

It also messes up aliasing optimizations.
 
 
 

error: invalid lvalue in increment

Post by Rod Pember » Fri, 08 Jun 2007 05:18:46


Hey, is that last line correct? It doesn't match your description...

address = (unsigned char *) a1;


Rod Pemberton
 
 
 

error: invalid lvalue in increment

Post by DJ Delori » Fri, 08 Jun 2007 05:49:14


Er, yeah, that one. No syntax checking in email :-P