From: "John M. Aldrich" Newsgroups: comp.os.msdos.djgpp Subject: Re: Borland library macro equivalent? Date: Thu, 24 Oct 1996 00:34:49 -0700 Organization: Three pounds of chaos and a pinch of salt Lines: 33 Message-ID: <326F1C19.1F4F@cs.com> References: <326EE107 DOT 1659 AT cs DOT com> Reply-To: fighteer AT cs DOT com NNTP-Posting-Host: ppp101.cs.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: eliz AT is DOT elta DOT co DOT il To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp John M. Aldrich wrote: > > Eli Zaretskii wrote: > > > > Ha! That's GCC we are using, remember? We don't need to suffer from no > > steenking double-evaluating compilers anymore: > > > > #define max(a,b) ({ typeof(a) _tmp_a = (a); \ > > typeof(b) _tmp_b = (b); \ > > (_tmp_a > _tmp_b) ? _tmp_a : _tmp_b; }) > > Is that C or C++ you're talking about? I thought only C++ let you > declare variables anywhere other than at the beginning of a block. Or > is this a special extension to the macro facility? > > Hmm, I guess I'd better go look through the docs some more. ;) Woops! I looked at the macro again after posting this message (well, I tried to stop it, but it obviously slipped in anyway...), and I saw what I missed the first time - those are braces in there, not parentheses. It's kinda hard to see in the Courier font. :) Anyway, that's a really neat trick, Eli, and it definitely would work. But do I take it that _only_ GNU C supports statement blocks in any expression? Seems like a fairly logical thing, really. -- --------------------------------------------------------------------- | John M. Aldrich, aka Fighteer I | fighteer AT cs DOT com | | * Proud user of DJGPP! * | http://www.cs.com/fighteer | | ObJoke: If Bill Gates were a robber, not only would he | | shoot you, but he'd send you a bill for the bullets. | ---------------------------------------------------------------------