9.2 #assert

The #assert preprocessing extensions of System V release 4 are permitted. These enable definition and testing of predicate names.

Such names are in a namespace distinct from all other names, including macro names.

Syntax

#assert name

#assert name[(token-sequence)]

Where:

name

is a predicate name

token-sequence

is an optional sequence of tokens.

If the token sequence is omitted, name is not given a value.

If the token sequence is included, name is given the value token-sequence.

Examples

A predicate name defined using #assert can be tested in a #if expression, for example:

#if #name(token-sequence)

This has the value 1 if a #assert of the name name with the token-sequence token-sequence has appeared, and 0 otherwise.

A predicate can have multiple values. That is, subsequent assertions do not override preceding assertions. For example:

#assert foo(one)      // Assigns the value "one"
#assert foo(two)      // Assigns the value "two"
#assert foo(three)    // Assigns the value "three"
#unassert foo(two)    // Unassigns the value "two"
        
#if #foo(one)...      // 1
#if #foo(two)...      // 0, because of #unassert
#if #foo(three)...    // 1
#if #foo(three)...    // 0, because this value was never asserted
Related reference
9.4 #unassert
Non-Confidential PDF file icon PDF version ARM DUI0472J
Copyright © 2010-2013 ARM. All rights reserved.