[Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]  


Nonstandard Predefined Macros

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
`unix' is normally predefined on all Unix systems.
BSD
`BSD' is predefined on recent versions of Berkeley Unix (perhaps only in version 4.3).

Other nonstandard predefined macros describe the kind of CPU, with more or less specificity. For example,

vax
`vax' is predefined on Vax computers.
mc68000
`mc68000' is predefined on most computers whose CPU is a Motorola 68000, 68010 or 68020.
m68k
`m68k' is also predefined on most computers whose CPU is a 68000, 68010 or 68020; however, some makers use `mc68000' and some use `m68k'. Some predefine both names. What happens in GNU C depends on the system you are using it on.
M68020
`M68020' has been observed to be predefined on some systems that use 68020 CPUs--in addition to `mc68000' and `m68k', which are less specific.
_AM29K
_AM29000
Both `_AM29K' and `_AM29000' are predefined for the AMD 29000 CPU family.
ns32000
`ns32000' is predefined on computers which use the National Semiconductor 32000 series CPU.

Yet other nonstandard predefined macros describe the manufacturer of the system. For example,

sun
`sun' is predefined on all models of Sun computers.
pyr
`pyr' is predefined on all models of Pyramid computers.
sequent
`sequent' is predefined on all models of Sequent computers.

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'.


[Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]