&
and |
)
NOTE
In the future, Taligent might support bool
, the new C++ built-in type for Booleans. For now, stick with the Taligent-defined type.
If you need to use sets of single-bit flags, don't use the
The bit-wise operators are useful in cases where bits must be laid out carefully in storage to match some existing definition or hardware registers, rather than left up to the vagaries of the compiler. However, such code is usually not portable and should be isolated. For more information on isolating code, see "Nonportable code" on page 143.
&
and |
operators to test and set these flags because doing so is error prone. (More than one bug has arisen from &
used instead of |
). Instead, use C++'s (and C's) bit-field facility. This lets the compiler allocate the storage and generate the code for testing and setting. Also, the compiler can take advantage of special instructions not accessible via |
and &
.
[Contents]
[Previous]
[Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.