Subject: Re: unix define
To: NetBSD-current Discussion List <current-users@NetBSD.ORG>
From: Chris G. Demetriou <firstname.lastname@example.org>
Date: 06/16/1998 08:55:09
> If life *were* so simple though we could rely on "unix" for marking
> major system differences. Without we end up with excessively horrid
> constructions such as the following *real* examples from *modern* code:
> #if defined (SUNOS4) || defined (__FreeBSD__) || defined (__NetBSD__)
> #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
> #if defined(__FreeBSD__)||defined(__NetBSD__)||defined(__bsdi__)||defined(LINUX)
> [ ... ]
> In each of the above cases a simple "#ifdef unix" would have sufficed,
> were it only reliable enough on modern machines to depend upon.
That's almost laughable.
SUNOS4 + NetBSD + FreeBSD + BSDI + OpenBSD + Linux, even all taken
together (and even if all were guaranteed to define 'unix'), do not
comprise the sum of systems that define 'unix'.
What if there's some system that defines 'unix' but breaks the code in
question. (Surely that wouldn't be too surprising...)
Then you get:
#if defined(unix) && (!defined(sys1) && !defined(sys2) ...)
which is no better, and is substantially less 'defensive'.