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

Pan ruochen panruochen@gmail.com
Thu Aug 19 08:21:00 GMT 2010


Hi All,

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? And there is another simple
substitution for that?

---
PRC
Aug 19,2010



More information about the Gcc-help mailing list