Re: Simple substitution for * ((unsigned short *)ptr)++ = XXXX ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 08/19/2010 08:21 AM, Pan ruochen wrote:

> This following statement fails in the latest gcc (4.3.3):
>  * ((unsigned short *)ptr)++ = XXXX;
> 
> The messages are: `lvalue required as increment operand'.
> It is really a very convenient way of saving to the current
> pointer and then moving the pointer forward or backward.
> 
> It is a little complex to replace the statement with
> 	* ((unsigned short *)ptr) = XXXX; ptr += sizeof(unsigned short);
> 
> Why gcc does not support the style?

Because it's not legal C.  We used to support it, but we stopped.

> And there is another simple
> substitution for that?

Not really.  IMO if you're going to do something like this, better to
spell it out.

Andrew.


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux