f78 Nonstandard Predefined Macros Contents|Index|Previous|Next
 

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 documentation, 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; for more information, see Invoking the C preprocessor. Some nonstandard predefined macros describe the operating system in use, with more or less specificity, as in the following examples.

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

This macro is usually specified in tm.h.
0