[comp.std.c] Please include architecture define in cpp

casey@admin.cognet.ucla.edu (Casey Leedom) (11/10/88)

  Sorry for taking so long to get back to this subject.  I've been totally
snowed under with a number of things, including my continuing efforts to
get X.V11R3 compiled under SR10, but more on that in a later letter ...

  Thanks to Larry Allen <lwa@apollo.com>, Leonard Zubkoff
<lnz@LUCID.COM>, and Ellis Jones <oj@apollo.COM> for information about
the Apollo compiler predefined defines m68000 (apparently for back
compatibility with previous releases of Apollo's development system), and
_ISP__M68K and _ISP__A88K under Apollo's new release, SR10.

  These defines do indeed allow me to determine the architecture of the
machine I'm compiling on so I can do the ``right thing'' for byte
ordering dependencies in structures for things like network independent
data, etc.  And, as was pointed out by Leonard Zubkoff,

	``The PRISM architecture is indeed big-endian; since Apollo is
	firmly committed to binary compatibility of data files, it would
	be very hard to change this in future architectures without
	losing that binary compatibility.''

it turns out not to matter too much.  Or rather, ``#ifdef apollo'' can
probably be taken as the same as ``#ifdef BIG_ENDIAN'' for the rest of
time (but I still prefer to ifdef on particular architectures to be
safe).

  But a question pops into my mind at this point: are these predefined
defines defined anywhere?  That is, does ANSI C define them?  Obviously
it couldn't define all of them because new architectures will be brought
to market, etc.  A set of standard ANSI C predefined architecture defines
would in fact almost seem to be the perfect thing to add to a new section
of the Assigned Numbers RFC that the NIC maintains.  Does anyone have any
information on this?

Casey

P.S.  I'm prompted to this question because 1. I've seen most compilers
    use "mc68000", not "m68000", and 2. the _ISP... defines look very
    ANSI Cish ...

gwyn@smoke.BRL.MIL (Doug Gwyn ) (11/11/88)

In article <17746@shemp.CS.UCLA.EDU> casey@cs.ucla.edu (Casey Leedom) writes:
>  But a question pops into my mind at this point: are these predefined
>defines defined anywhere?  That is, does ANSI C define them?  Obviously
>it couldn't define all of them because new architectures will be brought
>to market, etc.  A set of standard ANSI C predefined architecture defines
>would in fact almost seem to be the perfect thing to add to a new section
>of the Assigned Numbers RFC that the NIC maintains.  Does anyone have any
>information on this?

To provide a guarantee of purity of application-usable name spaces,
ANSI C forbids the implementation to predefine any macro names that
do not begin with a leading underscore followed by an upper-case
letter or a second underscore.  Thus a conforming implementation
cannot predefine symbols such as
	unix	vax	mc68000	u3b	apollo
However, _ISP__MC68K is permitted.

There is no known central registry for such implementation-supplied
names.  (It is certainly outside the scope of X3J11.)