From owner-freebsd-current Mon Mar 13 18:33: 8 2000 Delivered-To: freebsd-current@freebsd.org Received: from nscache2.x-treme.gr (mail1.x-treme.gr [212.120.196.23]) by hub.freebsd.org (Postfix) with ESMTP id DC55E37B64E for ; Mon, 13 Mar 2000 18:31:32 -0800 (PST) (envelope-from keramida@ceid.upatras.gr) Received: from hades.hell.gr (pat3.x-treme.gr [212.120.197.195]) by nscache2.x-treme.gr (8.9.3/8.9.3/IPNG-ADV-ANTISPAM-0.1) with ESMTP id EAA04528; Tue, 14 Mar 2000 04:30:26 +0200 Received: (from charon@localhost) by hades.hell.gr (8.9.3/8.9.3) id DAA19564; Tue, 14 Mar 2000 03:54:21 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Date: Tue, 14 Mar 2000 03:54:21 +0200 From: Giorgos Keramidas To: Bruce Evans Cc: John Polstra , paul@originative.co.uk, current@FreeBSD.ORG Subject: Re: MAX_UID ? Message-ID: <20000314035420.B17084@hades.hell.gr> Reply-To: keramida@ceid.upatras.gr References: <200003130145.RAA51429@vashon.polstra.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i In-Reply-To: ; from bde@zeta.org.au on Mon, Mar 13, 2000 at 05:28:47PM +1100 X-PGP-Fingerprint: 62 45 D1 C9 26 F9 95 06 D6 21 2A C8 8C 16 C0 8E X-Phone-Number: +30-94-6203692, +30-93-2886457 X-Address: Theodorou Kirinaiou 61, 26334 Patra, Greece Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Mon, Mar 13, 2000 at 05:28:47PM +1100, Bruce Evans wrote: ... > > I would prefer standard maxof() and minof() interfaces that work on > any arithmetic type. These can almost be written in portable C, at > least in C89 where types are restricted to char, signed char, ..., > long double: > > #define isfloat(type) ((type)0.5 != 0) > #define issigned(type) ((type)-1 < 0) > #define isschar(type) (!isfloat(type) && issigned(type) && sizeof(type) == 1) > #define isuchar(type) (!isfloat(type) && !issigned(type) && sizeof(type) == 1) > ... > #define maxof(type) ((type)(isschar(type) ? SCHAR_MAX : > isuchar(type) ? UCHAR_MAX ...)) This is marvellous in it's simplicity of interface. Yet, using sizeof(char) and assuming that it's going to be 1, strikes me like a dangerous thing to do. I have never heard of machines where this isn't true, but I seem to recall that the comp.lang.c FAQ mentions this somewhere. I'll look it up tomorrow, since it's getting too late.. - Giorgos Keramidas To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message