Date: Tue, 14 Mar 2000 03:54:21 +0200 From: Giorgos Keramidas <keramida@ceid.upatras.gr> To: Bruce Evans <bde@zeta.org.au> Cc: John Polstra <jdp@polstra.com>, paul@originative.co.uk, current@FreeBSD.ORG Subject: Re: MAX_UID ? Message-ID: <20000314035420.B17084@hades.hell.gr> In-Reply-To: <Pine.BSF.4.21.0003131708430.931-100000@alphplex.bde.org>; from bde@zeta.org.au on Mon, Mar 13, 2000 at 05:28:47PM %2B1100 References: <200003130145.RAA51429@vashon.polstra.com> <Pine.BSF.4.21.0003131708430.931-100000@alphplex.bde.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000314035420.B17084>