Date: Wed, 20 Jun 2001 12:36:12 -0500 From: Mike Meyer <mwm@mired.org> To: j mckitrick <jcm@FreeBSD-uk.eu.org> Cc: questions@freebsd.org Subject: Re: what does this define do? Message-ID: <15152.57100.616134.239729@guru.mired.org> In-Reply-To: <21323580@toto.iv>
next in thread | previous in thread | raw e-mail | index | archive | help
j mckitrick <jcm@FreeBSD-uk.eu.org> types:
> at the risk of making a fool of myself (one which i am never hesitant to
> take ;-) could someone explain to me how this macro
>
> #define n(flags) (~(flags) & (flags))
>
> is different from this one?
>
> #define n(flags) 0
The first one can evaluate flags twice. If flags changes between the
evaluations, the value can be something other than zero. Here's a QAD
example:
#include <stdio.h>
#define n(flags) (~(flags) & (flags))
int x ;
int
f() {
return x++ ;
}
main() {
int c ;
for (c = 0; c < 64; c += 1) {
x = c ;
printf("n(%d) is %d\n", c, n(f())) ;
}
}
This isn't a practice I'd recommend, though.
<mike
--
Mike Meyer <mwm@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?15152.57100.616134.239729>
