delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2006/05/15/23:01:29

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
Received-SPF: None; receiver=nym.alias.net; client-ip=213.250.81.164;
envelope-from=<aw AT aw DOT gs>; helo=mariah.narpes.com
Date: Tue, 16 May 2006 02:54:48 +0000 (GMT)
From: "A. Wik" <aw AT aw DOT gs>
Subject: Re: error: invalid lvalue in increment
In-Reply-To: <e4b5he$1b14$1@defiant.vmunix.org>
Message-ID: <20060516022841.L2491@dynamite.narpes.com>
References: <44670d4b$0$3880$91cee783 AT newsreader01 DOT highway DOT telekom DOT at>
<e4b5he$1b14$1 AT defiant DOT vmunix DOT org>
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
Organization: none
Mail-To-News-Contact: postmaster AT nym DOT alias DOT net
Lines: 86
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

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


On Mon, 15 May 2006, Rod Pemberton wrote:

> 
> "Florian Xaver" <wosrediinanatour AT aon DOT at> wrote in message
> news:44670d4b$0$3880$91cee783 AT newsreader01 DOT highway DOT telekom DOT at...
> > What is wrong?
> >
> > ...
> > (l_text)d += 1;
> > *d = GetKey(App) & 0xFF;
> > ...
> >
> 
> 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
> 
> 
> 




















- Raw text -


  webmaster     delorie software   privacy  
  Copyright 2019   by DJ Delorie     Updated Jul 2019