From owner-freebsd-questions Wed Jun 20 10:36:16 2001 Delivered-To: freebsd-questions@freebsd.org Received: from guru.mired.org (okc-65-26-235-186.mmcable.com [65.26.235.186]) by hub.freebsd.org (Postfix) with SMTP id DD9CA37B401 for ; Wed, 20 Jun 2001 10:36:13 -0700 (PDT) (envelope-from mwm@mired.org) Received: (qmail 4647 invoked by uid 100); 20 Jun 2001 17:36:12 -0000 From: Mike Meyer MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15152.57100.616134.239729@guru.mired.org> Date: Wed, 20 Jun 2001 12:36:12 -0500 To: j mckitrick Cc: questions@freebsd.org Subject: Re: what does this define do? In-Reply-To: <21323580@toto.iv> X-Mailer: VM 6.90 under 21.1 (patch 14) "Cuyahoga Valley" XEmacs Lucid X-face: "5Mnwy%?j>IIV\)A=):rjWL~NB2aH[}Yq8Z=u~vJ`"(,&SiLvbbz2W`;h9L,Yg`+vb1>RG% *h+%X^n0EZd>TM8_IB;a8F?(Fb"lw'IgCoyM.[Lg#r\ Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG j mckitrick 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 #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. 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