more on TRUE and FALSE (side-comment)
Henry Spencer
henry at zoo.toronto.edu
Wed Sep 19 02:35:33 AEST 1990
In article <quan.653570879 at sol> quan at sol.surv.utas.oz (Stephen Quan) writes:
>Personally I hate 'writing' programs with :
>
> if (strcmp(name,"hippo")==0) ....
Agreed. This is a *very* confusing convention, made all the worse by
pinheads who shorten it to `if (strcmp(a, b))' or `if (!strcmp(a, b))'
without considering what a nuisance this is to readers. Our local
custom is to define a STREQ macro; the inequality comparisons are much
less troublesome (and much rarer) and don't really need the help. My
current favorite definition is:
#define STREQ(a, b) (*(a) == *(b) && strcmp((a), (b)) == 0)
Note that this is an unsafe macro; on the other hand, it is typically
much faster than one which just calls strcmp every time. Most string
comparisons fail on the first character.
--
TCP/IP: handling tomorrow's loads today| Henry Spencer at U of Toronto Zoology
OSI: handling yesterday's loads someday| henry at zoo.toronto.edu utzoo!henry
More information about the Comp.lang.c
mailing list