ILE C/C++ Programmer's Guide

Decimal Constants and Case Statements

The __D macro is used to simplify code that requires the frequent use of the _ConvertDecimal constructor. Because the __D macro is equivalent to the _ConvertDecimal constructor, the __D macro cannot used be with a case statement. A valid case statement uses an integral constant expression. This code shown in the following figure results in a compiler error:

Figure 208. Example of Code with Decimal Constants and a Case Statement that Are Incompatible


 decimal(4,3) op;
 
 switch int(op) {
     case int(__D("1.3")):
        .....
        break;
 }
Note:
The compiler flags the case statement indicating that the case expression is not an integral constant expression.


[ Top of Page | Previous Page | Next Page | Table of Contents ]