From mint-bounce@lists.fishpool.fi Tue Jan 22 17:33:48 2008 X-Original-To: fnaumann@mail.boerde.de Delivered-To: fnaumann@mail.boerde.de Message-ID: <478A95E4.3070106@freesbee.fr> Date: Sun, 13 Jan 2008 23:51:16 +0100 From: =?ISO-8859-1?Q?Vincent_Rivi=E8re?= User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 To: mint Subject: Re: [MiNT] sys/param.h change for GCC 4 compatibility References: <1200263361.21985.2.camel@localhost> In-Reply-To: <1200263361.21985.2.camel@localhost> Content-Type: text/plain; charset=ISO-8859-1; format=flowed X-ecartis-version: Ecartis v1.0.0 Sender: mint-bounce@lists.fishpool.fi Errors-To: mint-bounce@lists.fishpool.fi X-original-sender: vincent.riviere@freesbee.fr Precedence: bulk List-help: List-unsubscribe: List-Id: X-List-ID: List-subscribe: List-owner: List-post: 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=-1.0 tagged_above=-50.5 required=7.0 tests=BAYES_00 X-Spam-Level: Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by freemint id m0MGP1eX004618 Status: X-Status: X-Keywords: Alan Hourihane wrote : > Here's a patch to MiNTlibs sys/param.h so that GCC 4 is happy too. > /* Macros for min/max. */ > -#ifndef MIN > -#define MIN(a,b) \ > - ({__typeof__ (a) _a = (a); __typeof__ (b) _b = (b); \ > - _a < _b ? _a : _b; }) > -#endif > -#ifndef MAX > -#define MAX(a,b) \ > - ({__typeof__ (a) _a = (a); __typeof__ (b) _b = (b); \ > - _a > _b ? _a : _b; }) > -#endif > +#define MIN(a,b) (((a)<(b))?(a):(b)) > +#define MAX(a,b) (((a)>(b))?(a):(b)) Sorry but I have no problem with the current implementation. Furthermore, it avoids multiple evaluation of the arguments, unlike the traditional implementation you propose. However, I have a warning when compiling with -pedantic: warning: ISO C forbids braced-groups within expressions It can be avoided by inserting __extension__ before the body of the macros : #define MIN(a,b) \ __extension__({__typeof__ (a) _a = (a); __typeof__ (b) _b = (b); \ _a < _b ? _a : _b; }) This technique is used for the traps in . Did you find something else wrong ? -- Vincent Rivière