From: Mark Williamson Subject: Re: question regarding gnu-isms Date: Fri, 28 Apr 2006 00:08:46 +0100 Message-ID: <200604280008.47804.mark.williamson@cl.cam.ac.uk> References: <20060427223641.GG3572@vino.zko.hp.com> <44514DE1.3000201@us.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <44514DE1.3000201@us.ibm.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com Cc: aron@hp.com List-Id: xen-devel@lists.xenproject.org OK, now I'm curious too... > > same file: > > > > #define xen_create_contiguous_region(vstart, order, address_bits) > > ({0;}) > > But clearly you cannot use return for this (and you cannot avoid making > a statement here). The GNU ({}) syntax allows you to have statements > within an expression and the value of the very last statement in the > block becomes the value of the expression. The above could be written: But why do that, if you just wanted to return a constant? why not #define xen_create_contiguous_region(vstart, order, address_bits) 0 for instance? Cheers, Mark > > #define min(a, b) ({int lhs = a; int rhs = b; (lhs < rhs) ? lhs : rhs;}) > > All of these are documented in the GCC Info page (see the section on C > Extensions). > > Regards, > > Anthony Liguori > > > This looks like the usual ({...}) construction but seems > > pointless. The nearest explanation I could gather for this > > applies only to C++... surely I'm missing something. :-) > > > > Thanks, > > Aron > > > > _______________________________________________ > > Xen-devel mailing list > > Xen-devel@lists.xensource.com > > http://lists.xensource.com/xen-devel > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xensource.com > http://lists.xensource.com/xen-devel -- Dave: Just a question. What use is a unicyle with no seat? And no pedals! Mark: To answer a question with a question: What use is a skateboard? Dave: Skateboards have wheels. Mark: My wheel has a wheel!