more on TRUE and FALSE (side-comment)

Karl Heuer karl at haddock.ima.isc.com
Sat Sep 22 09:49:38 AEST 1990


In article <14084:Sep2105:38:0890 at kramden.acf.nyu.edu> brnstnd at kramden.acf.nyu.edu (Dan Bernstein) writes:
>#define STREQ(a,b)  ( *(a) == *(b) && *(a) && !strcmp((a)+1, (b)+1) )

Nope.  Try
#define STREQ(a,b)  ( *(a) == *(b) && (*(a)=='\0' || strcmp((a)+1, (b)+1)==0) )

(or the equivalent but muddier construct:)
#define STREQ(a,b)  ( *(a) == *(b) && !(*(a) && strcmp((a)+1, (b)+1)) )

Or just use the original macro, but conditionalize it on HAVE_INLINE_STRCMP.

Karl W. Z. Heuer (karl at kelp.ima.isc.com or ima!kelp!karl), The Walking Lint



More information about the Comp.lang.c mailing list