[cfe-dev] [RFC] Compiler warning -Wparentheses for code : while (c = *str++)

Joerg Sonnenberger joerg at britannica.bec.de
Wed Aug 12 03:39:36 PDT 2015


On Tue, Aug 11, 2015 at 11:37:51PM -0700, Justin Bogner wrote:
> This tells you what to do to avoid the warning, spell this like so:
> 
>   while ((c = *str++)) {
>     *p++ = (c >= 'A' && c <= 'Z') ? (c - 'A' + 'a') : c;
>   }

Alternatively, you can declare c in the loop as well:

while (char c = *str++) ...

Joerg



More information about the cfe-dev mailing list