warning question

mike antispam21 at verizon.net
Mon May 11 21:54:14 UTC 2009


But how did you not get a 1 with a single '!'?

(From ANSI C: The result of the logical negation operator ! is 0 if the 
value of its operand compares
unequal to 0, 1 if the value of its operand compares equal to 0. The 
result has type int.
The expression !E is equivalent to (0==E).)


Arnout Vandecappelle wrote:
> On Wednesday 06 May 2009 17:49:28 Joel Sherrill wrote:
>   
>> Hi,
>>
>> I am looking at warnings and wondered if someone
>> could figured this one out.
>>
>> c/src/libchip/network/i82586.c:1722: warning: suggest parentheses around
>> operand of '!' or change '|' to '||' or '!' to '~'
>>
>> The code is clearly questionable IMO. ;)
>>
>>   *IE_CMD_CFG_PROMISC(buf)   = !!promiscuous | manchester << 2;
>>     
>
>  This means (!!promiscuous) | (manchester << 2).  It looks OK to me, though 
> adding parenthases around as I did certainly makes things clearer.
>
>  The !! is a trick to make sure you have a 1, not just any non-zero int.
>
>  Regards,
>  Arnout
>   





More information about the users mailing list