Subject: Re: unix define
To: None <current-users@NetBSD.ORG>
From: Greg A. Woods <email@example.com>
Date: 06/16/1998 11:50:13
[ On Tue, June 16, 1998 at 00:50:59 (-0700), Erik E. Fair wrote: ]
> Subject: Re: unix define
> Larry Wall discovered long ago to do his #ifdef's on *features* rather than
> systems. Features can be tested for by a configuration script. Operating
> System feature sets change over time, and no two versions of "unix" have
> exactly the same feature set.
> Depending on "unix" is foolhardy for any programmer who wants to write
> portable code.
Of course, but if only life were so simple. I for one am not talking
about new code, but rather ancient stuff. The pkgsrc patch mechanism is
only a partial solution and will not be used for all instances. Not all
NetBSD users are code maintainers either, but I hope we don't want to
make their lives any more difficult than they already are.
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__)
I'm sure you can imagine how ugly these will be once they've been
updated to support all variants they may encounter. Even combining only
the above variants into one complete super-set is bad enough.
In each of the above cases a simple "#ifdef unix" would have sufficed,
were it only reliable enough on modern machines to depend upon. If we
could be sure our software only needed to run on really modern and
standards conformant system then perhaps _XOPEN_UNIX would do, but
that's a blue-sky dream too.
Greg A. Woods
+1 416 443-1734 VE3TCP <firstname.lastname@example.org> <robohack!woods>
Planix, Inc. <email@example.com>; Secrets of the Weird <firstname.lastname@example.org>