cpp: Obsolete Features
1
1 11.3 Obsolete Features
1 ======================
1
1 CPP has some features which are present mainly for compatibility with
1 older programs. We discourage their use in new code. In some cases, we
1 plan to remove the feature in a future version of GCC.
1
1 11.3.1 Assertions
1 -----------------
1
1 "Assertions" are a deprecated alternative to macros in writing
1 conditionals to test what sort of computer or system the compiled
1 program will run on. Assertions are usually predefined, but you can
1 define them with preprocessing directives or command-line options.
1
1 Assertions were intended to provide a more systematic way to describe
1 the compiler's target system and we added them for compatibility with
1 existing compilers. In practice they are just as unpredictable as the
1 system-specific predefined macros. In addition, they are not part of
1 any standard, and only a few compilers support them. Therefore, the use
1 of assertions is *less* portable than the use of system-specific
1 predefined macros. We recommend you do not use them at all.
1
1 An assertion looks like this:
1
1 #PREDICATE (ANSWER)
1
1 PREDICATE must be a single identifier. ANSWER can be any sequence of
1 tokens; all characters are significant except for leading and trailing
1 whitespace, and differences in internal whitespace sequences are
1 ignored. (This is similar to the rules governing macro redefinition.)
1 Thus, '(x + y)' is different from '(x+y)' but equivalent to '( x + y )'.
1 Parentheses do not nest inside an answer.
1
1 To test an assertion, you write it in an '#if'. For example, this
1 conditional succeeds if either 'vax' or 'ns16000' has been asserted as
1 an answer for 'machine'.
1
1 #if #machine (vax) || #machine (ns16000)
1
1 You can test whether _any_ answer is asserted for a predicate by
1 omitting the answer in the conditional:
1
1 #if #machine
1
1 Assertions are made with the '#assert' directive. Its sole argument
1 is the assertion to make, without the leading '#' that identifies
1 assertions in conditionals.
1
1 #assert PREDICATE (ANSWER)
1
1 You may make several assertions with the same predicate and different
1 answers. Subsequent assertions do not override previous ones for the
1 same predicate. All the answers for any given predicate are
1 simultaneously true.
1
1 Assertions can be canceled with the '#unassert' directive. It has
1 the same syntax as '#assert'. In that form it cancels only the answer
1 which was specified on the '#unassert' line; other answers for that
1 predicate remain true. You can cancel an entire predicate by leaving
1 out the answer:
1
1 #unassert PREDICATE
1
1 In either form, if no such assertion has been made, '#unassert' has no
1 effect.
1
1 You can also make or cancel assertions using command-line options.
1 ⇒Invocation.
1