From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marc Lehmann To: egcs@cygnus.com Subject: Re: [EGCS] Re: min/max macros Date: Thu, 11 Dec 1997 17:57:00 -0000 Message-id: <19971212025753.58271@cerebro.laendle> References: <01BD0625.FDFCC640@bill.icdata.com> X-SW-Source: 1997-12/msg00686.html > > #define max(a,b) (((a) > (b)) ? (a) : (b)) > > #define min(a,b) (((a) < (b)) ? (a) : (b)) > > That is a big no-no: Absolutely no performance benefits with any decent > compiler but nasty side effects. so egcs isn't a decent compiler? for example, the macro-max(2,3) will be evaluated at compile time, while the function-max(2,3) won't... this get's even worse on things like: int mult(int a, int b) { return a*b; }; mult(a,3) will result in an "imul 3" on x86... definitely slower than a lea, for example. -----==- | ----==-- _ | ---==---(_)__ __ ____ __ Marc Lehmann +-- --==---/ / _ \/ // /\ \/ / pcg@goof.com |e| -=====/_/_//_/\_,_/ /_/\_\ --+ The choice of a GNU generation | |