Sun WorkShop Compiler C 5.0 User's Guide

Assertions

A line of the form:


#assert predicate (token-sequence) 

associates the token-sequence with the predicate in the assertion name space (separate from the space used for macro definitions). The predicate must be an identifier token.


#assert predicate 

asserts that predicate exists, but does not associate any token sequence with it.

The compiler provides the following predefined predicates by default (not in -Xc mode):


#assert
system (unix)
#assert machine (sparc)(SPARC)
#assert machine (i386)(Intel)
#assert cpu (sparc)(SPARC)
#assert cpu (i386)(Intel)

lint provides the following predefinition predicate by default (not in -Xc mode):


#assert lint (on)

Any assertion may be removed by using #unassert, which uses the same syntax as assert. Using #unassert with no argument deletes all assertions on the predicate; specifying an assertion deletes only that assertion.

An assertion may be tested in a #if statement with the following syntax:


#if #predicate(non-empty token-list) 

For example, the predefined predicate system can be tested with the following line:


#if #system(unix) 

which evaluates true.