Determining system type

Guy Harris guy at auspex.UUCP
Mon Mar 6 12:20:33 AEST 1989


>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?

No.

I suspect you're really not interested in whether you're on a "BSD" or
"AT&T" system; you're probably *really* interested in "does this feature
exist on my system?" or "how should I perform some particular
operation?"

Well, in some ways, the "AT&T" system V7 is more like the "BSD" system
4.2BSD than like the "AT&T" system "System III" or "System V".  In other
ways, it's more like the other "AT&T" systems.  And, in some ways, later
releases of S5 are more like BSD than V7!  (V7 had neither the "mkdir" nor
the "rmdir" system call, nor the "directory library" - "opendir",
"readdir", etc..)

In addition, although some system may be thought of as "BSD-based", it
may have the S5 feature you're looking for, or a "S5-based" system may
have the BSD feature you're looking for.

And, just to top things off, there may be features present in *some*
"BSD-based" systems, as well as *some* "S5-based" systems, but not
present in others.

Trying to split the world into "AT&T" and "BSD" systems won't work.  The
world is more complicated than that.

You should, instead, try to determine whether the particular feature for
which you're looking is present.  Your example is an almost-correct way
of determining whether UNIX-domain sockets are present, although you
should:

	1) be including <sys/stat.h>, not <stat.h>

	2) be including <sys/types.h> before <sys/stat.h>

	3) be testing whether "S_IFSOCK" is defined, not "S_ISOCK".

In some cases, there is no magic #define that will tell you whether a
feature is present or not.



More information about the Comp.unix.questions mailing list