Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!pasteur!ames!haven!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn ) Newsgroups: comp.unix.questions Subject: Re: Determining system type Message-ID: <9795@smoke.BRL.MIL> Date: 5 Mar 89 20:39:39 GMT References: <327@wubios.wustl.edu> <15406@cup.portal.com> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 18 In article <15406@cup.portal.com> gregh@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 >#if defined(S_ISOCK) You could also test what 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.