On 4/10/2012 1:19 PM, Antoine Leca wrote:
> Eric Sosman wrote in<news:jllkpe$pkg$>:
>> On 4/5/2012 12:11 PM, Antoine Leca wrote:
>>> A colleague went on shutting off the warning, by replacing
>>> #define islower(c) ((int)((_ctype_ + 1)[(c)]& _L))
>>> [...]
>>> Do you have better options (in the real world)?
>>
>> #include<ctype.h>
>> #define local_islower(x) islower((unsigned char)(x))
>>
>> Takes care of the transformation your colleague wants,
>
> Sorry, a detail here is missed; my colleague does not want to transform
> the meaning of the source (which neither him nor I control), he merely
> wanted to shut the compiler up in a quick way.
"That's -- Your -- Funeral!" -- Mr. and Mrs. Sowerberry
You and your colleague take the batteries out of the smoke alarms
at your peril. You may well survive, and snigger at doomsayers like
me, and say "What an old fussbudget!"
Three facts about Cassandra: (1) She invariably prophesied disaster,
(2) nobody ever believed her, and (3) she was always right.
> Tim Rentsch wrote<news:>:
>> Assuming you really want to allow such code and have it not give
>> a warning, I expect
>>
>> #define islower(c) ((int)((_ctype_ + 1)[(c)+0]& _L))
>>
>> would eliminate the warning without changing the semantics.
This is likely to silence the compiler (not certain to, as the
compiler is free to emit any warnings it cares to -- indeed, the very
warning you're fretting over is not required by the Standard). It
does not, however, fix the underlying problem: If the value of `c' is
less than -1, the macro will misbehave. (Replacing `+1' with `-EOF'
would let you imagine you're writing portable code, but it would still
be only an illusion.)
But, hey: "That's -- Your -- Funeral!"
--
Eric Sosman
d