From mint-bounce@lists.fishpool.fi  Thu Apr 28 12:40:15 2005
X-Original-To: fnaumann@mail.boerde.de
Delivered-To: fnaumann@mail.boerde.de
To: Evan Langlois <Evan@CoolRunningConcepts.com>
Cc: MiNT Mailing List <mint@fishpool.com>
Subject: Re: [MiNT] compiling problem
References: <Pine.LNX.4.62.0504281043240.4074@localhost.localdomain>
	<1114682277.18332.40.camel@taro.coolrunningconcepts.com>
From: tomas@nocrew.org (=?iso-8859-1?q?Tomas_Sk=E4re?=)
Date: Thu, 28 Apr 2005 12:37:10 +0200
In-Reply-To: <1114682277.18332.40.camel@taro.coolrunningconcepts.com> (Evan
 Langlois's message of "Thu, 28 Apr 2005 04:57:52 -0500")
Message-ID: <80r7gv6vc9.fsf@junk.nocrew.org>
User-Agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-ecartis-version: Ecartis v1.0.0
Sender: mint-bounce@lists.fishpool.fi
Errors-To: mint-bounce@lists.fishpool.fi
X-original-sender: tomas@nocrew.org
Precedence: bulk
List-help: <mailto:ecartis@lists.fishpool.fi?Subject=help>
List-unsubscribe: <mailto:mint-request@lists.fishpool.fi?Subject=unsubscribe>
List-Id: <mint.lists.fishpool.fi>
X-List-ID: <mint.lists.fishpool.fi>
X-Virus-Scanned: by amavisd-new at relay.boerde.de
X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on relay.boerde.de
X-Spam-Status: No, hits=2.1 tagged_above=-50.5 required=7.0 tests=BAYES_00,
 RCVD_IN_SORBS
X-Spam-Level: **

Evan Langlois <Evan@CoolRunningConcepts.com> writes:

> Anyway, its not MiNT's fault, although the #define for min() I normally
> see is something a bit simpler without all the assignment and local
> variable allocation, its still Sox's fault.

IMO, it would be better to write the macro in capitals, MIN(a,b)
instead, if it should be in the header files at all. 

> Perhaps the maintainer of
> mintlib, or someone wiser than I, can tell me what's wrong with this:
>
> #define min(a,b)	(((a) < (b)) ? (a) : (b))

Either a or b are evaluated twice here, which does not happen with the
current one. If you write code like:

 m = min(a++, b++);

you expect a and b to be increased with 1. One of them will be
increased with 2, if you use your simple macro.

Despite that, your version seems to be the more commonly used
anyway. You just have to know of the potential problem, when using
it.


Greetings,

Tomas


