apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Branko ─îibej <br...@xbc.nu>
Subject Re: [PATCH] How to Use strcmp to Check for Equality Without Confusing Your Fellow Code, Or: Isn't There a Macro for That?
Date Wed, 20 Oct 2010 19:03:38 GMT
 On 20.10.2010 16:48, Ralf Mattes wrote:
> I think '!strcmp(' treats strcmp as returning a "generalized boolean" [1]
> 1 which it plain and simply isn't. It would have been nice if the ISO 
> standard would have restricted the return value to {-1,0,1} because then
> we could use enums/defines like FIRST_SMALLER, EQUAL  and SECOND_SMALLER 

You can still have those defines, but as macros around strcmp, not as

> but unfortunately the didn't (must have been that major performance boost
> you get from returning a[i] - b[i] ... :-)

Apparently you forget how fantastically good optimizing compilers were
back in the day when C first appeared. The standard just documents
existing practice, and it would've been major breakage if the standard
said something else than what compilers have been doing for 40 years ...

-- Brane

View raw message