Determining system type

Doug Gwyn gwyn at smoke.BRL.MIL
Mon Mar 6 06:39:39 AEST 1989


In article <15406 at cup.portal.com> gregh at cup.portal.com (Greg S Hinton) writes:
>Is there a "standard" -- or optimal -- way to determine at compile time
>whether one is on a BSD or AT&T (Ver7, SysIII, SysV) system?
>This is the best I've been able to come up with so far:
>#include <stat.h>
>#if defined(S_ISOCK)

You could also test what <sgtty.h> defines.

The real problem is that you're assuming that there are well-defined,
"pure" BSD vs. AT&T environments.  In practice, vendors have grafted
some bits of other systems into their implementations.  This will
reach its zenith with UNIX System V Release 4.  Instead of trying to
conditionalize on "system type", consider tailoring for the exact
features you're interested in; this often requires adding -Ds to
CFLAGS in the Makefile to set the appropriate "feature test macros".
Another viable solution is to isolate all system dependencies in
separate modules, compiling whichever module is appropriate.



More information about the Comp.unix.questions mailing list