Description
The C compiler issued with AT&T Unix.
This compiler doesn't have any identifying macros, nor seemingly do any
header files provide any realistic means of identifying either the compiler
or the underlying AT&T Unix.
I think it might be somewhat 'safe' to assume that an actual AT&T
Unix system would be the "porting base" for that relevant
version.
Porting Bases
Release |
Porting Base |
SVR1 |
PDP-11 and VAX |
SVR2 |
VAX-11/780 and NS32000. |
SVR3 |
3B2 |
SVR4 |
Intel x86 and SPARC[1,2] |
- There is a release of AT&T Unix System V Release 4 for 386, but
I have not played around with that yet.
- There is also a release of System V Release 4.0 for the 3B2.
Macros
As AT&T's compiler lacks any means of identification via preprocessor,
we need alternates.
These are identifiers provided to identify the underlaying platform.
Type |
Macro |
Earliest |
Description |
Identification |
u3b2 |
SVR3 |
Defined on AT&T
3B2 hardware. |
Identification |
u3b5 |
SVR3 |
Defined on AT&T
3B5 hardware. |
Identification |
u3b |
SVR2 |
Present in SVR3.2. |
Identification |
ns32000 |
SVR2 |
Defined on NS32K hardware,
only in SVR2 |
Identification |
vax |
SVR2 |
Defined on DEC VAX hardware. |
Identification |
pdp11 |
SVR1 |
Defined on DEC PDP-11
hardware. |
Identification |
i386 |
SVR4 |
Defined on Intel x86
hardware. |
Identification |
unix |
SVR1 |
Defined with any
derivative of AT&T Unix. |
On SVR2, /lib/cpp
defines
vax
and pdp11
.
On SVR3, /lib/cpp
defines
u3b2
, u3b5
,
and u3b20d
.
The following are defined for cross-compilation environments: unix
,
gcos
, ibm
,
DMERT
.
The following are defined "for historical reasons" only: tss
,
os
, mert
,
RT
, RES
.
The following are defined for both target machines: interdata
,
pdp11
, vax
,
u370
, u3b
,
u3b5
, u3b2
,
u3b20d
, ns32000
,
i386
.
Example
Note: this is untested.
/*
* Other Unix systems should be detected first, as all of them
* will have 'unix' defined -- e.g. with this code, ULTRIX on VAX will
* magically appear to be a System V which is wrong, as it's BSD-derived.
*/
#ifdef unix
# if defined(pdp11)
printf("AT&T Unix System V Release 1\n");
# elif defined(vax) || defined(ns32000)
printf("AT&T Unix System V Release 2\n");
# elif defined(u3b2)
printf("AT&T Unix System V Release 3\n");
# elif defined(i386) || defined(sparc)
printf("AT&T Unix System V Release 4\n");
# else
printf("Probably isn't AT&T Unix.\n");
# endif
#endif
|
This seems to work on AT&T System V Release 3.2.3 for 3B2
$ uname -a; ./test
borman borman 3.2.3 3 3B2
AT&T Unix System V Release 3
$ |
It might seem strange to have code to detect a Unix system here under
compiler macros, but this is probably the best way to handle
the AT&T compiler. If you match AT&T Unix, then you can assume
that the compiler is the AT&T compiler.
Notes
These sorts of shenanigans continues with all derivatives of System V
Release 3, notably Xenix and SCO Unix.
SCO System V Release 5 also slightly conflates this. I think the mentality
was "This is Unix, we do not need to define anything that identifies what
sort of Unix, because this is Unix."