The C preprocessor normally has several predefined macros that vary between machines because their purpose is to indicate what type of system and machine is in use. This manual, being for all systems and machines, cannot tell you exactly what their names are; instead, we offer a list of some typical ones. You can use `cpp -dM' to see the values of predefined macros; see section Invoking the C Preprocessor.
Some nonstandard predefined macros describe the operating system in use, with more or less specificity. For example,
unix
BSD
Other nonstandard predefined macros describe the kind of CPU, with more or less specificity. For example,
vax
mc68000
m68k
M68020
_AM29K
_AM29000
ns32000
Yet other nonstandard predefined macros describe the manufacturer of the system. For example,
sun
pyr
sequent
These predefined symbols are not only nonstandard, they are contrary to the ANSI standard because their names do not start with underscores. Therefore, the option `-ansi' inhibits the definition of these symbols.
This tends to make `-ansi' useless, since many programs depend on the customary nonstandard predefined symbols. Even system header files check them and will generate incorrect declarations if they do not find the names that are expected. You might think that the header files supplied for the Uglix computer would not need to test what machine they are running on, because they can simply assume it is the Uglix; but often they do, and they do so using the customary names. As a result, very few C programs will compile with `-ansi'. We intend to avoid such problems on the GNU system.
What, then, should you do in an ANSI C program to test the type of machine it will run on?
GNU C offers a parallel series of symbols for this purpose, whose names
are made from the customary ones by adding `__' at the beginning
and end. Thus, the symbol __vax__
would be available on a Vax,
and so on.
The set of nonstandard predefined names in the GNU C preprocessor is
controlled (when cpp
is itself compiled) by the macro
`CPP_PREDEFINES', which should be a string containing `-D'
options, separated by spaces. For example, on the Sun 3, we use the
following definition:
#define CPP_PREDEFINES "-Dmc68000 -Dsun -Dunix -Dm68k"
This macro is usually specified in `tm.h'.