Sender: nate AT cartsys DOT com Message-ID: <36D9C304.4415513@cartsys.com> Date: Sun, 28 Feb 1999 14:28:20 -0800 From: Nate Eldredge X-Mailer: Mozilla 4.08 [en] (X11; I; Linux 2.2.1 i586) MIME-Version: 1.0 To: djgpp AT delorie DOT com Subject: Re: sin, cos ?? References: <3 DOT 0 DOT 6 DOT 32 DOT 19990228075415 DOT 008acda0 AT pop DOT globalserve DOT net> <3 DOT 0 DOT 6 DOT 32 DOT 19990228114416 DOT 0097d4c0 AT pop DOT globalserve DOT net> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Reply-To: djgpp AT delorie DOT com Paul Derbyshire wrote: > Can Nate make this work without side effect problems? > > #define MAX(a,b) (((a) > (b)) ? (a) : (b)) I can, but in order not to reinvent the wheel I'll use RMS's code (section "Naming an expression's type" from /Using and Porting GNU CC/) #define max(a,b) \ ({typedef _ta = (a), _tb = (b); \ _ta _a = (a); _tb _b = (b); \ _a > _b ? _a : _b; }) Gotta love those GCC extensions. (Okay, so it won't work in ANSI C. Can you write a single function or macro in it, or ANSI C++, that will safely find the maximum of two arguments of any types?) -- Nate Eldredge nate AT cartsys DOT com