compare strings, strcmp
Michael T. Sullivan
sullivan at aqdata.uucp
Sat Nov 18 02:51:43 AEST 1989
>From article <309 at charyb.COM>, by will at charyb.COM (Will Crowder):
> In article <308 at charyb.COM> dan at charyb.UUCP (Dan Mick) writes:
>
>>In article <11605 at smoke.BRL.MIL> gwyn at brl.arpa (Doug Gwyn) writes:
>>>#define StrEq( a, b ) (*(a) == *(b) && strcmp( a, b ) == 0)
>>>/* UNSAFE */
>>
>>Why the UNSAFE comment? This looks like utterly standard C to me...
>
> This macro is "unsafe" because the macro arguments a and b are used twice,
> hence possible side effect difficulties...
I once read (Indian Hills Style Guide???) that if a macro doesn't behave
EXACTLY like a function (i.e. evaluates parameters once, doesn't assign
to arguments, etc.) that it should be named in all caps. Thus, a person
using the macro will know to be careful with it. Applies here, eh?
--
Michael Sullivan uunet!jarthur.uucp!aqdata!sullivan
aQdata, Inc.
San Dimas, CA
More information about the Comp.lang.c
mailing list