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

Re: lvalue depreciated

> I get the following message with the following code fragment. Could anyone
> tell me what's the point here? Thanks.
> warning: use of cast expressions as lvalues is deprecated
>   ((u16 *)dch)++;        // Skip length
>   mode = *dch++;

Strictly saying, (u16 *)dch is a value of dch, converted to type 'u16 *',
not the variable 'dch' thought as a variable of 'u16 *' type. You can't
increment a value, unless address where it is stored is given.

Try *((u16 **)(&dch))++. In this form, you explicitly tell compiler to
increment the value stored at the address of 'dch' variable.

Or - if dch is a char *, better to write something like
  dch += sizeof(u16)

Reply to: