ILE C/C++ Programmer's Guide

Using Debug Macros for _DecimalT Class Templates

C++ exception handling is used in the _DecimalT class template. If an error is detected during run time, an error object is thrown.

Table 29 defines the three macros that you can use to turn assertion-checking on and off.

Table 29. Debug Macros for _DecimalT Class Templates

Macro Meaning
_DEBUG Assertion checking is on.
_DEBUG_DECIMAL Assertion checking is on for the _DecimalT class template only.
_NODEBUG_DECIMAL Default: Assertion checking is off. This macro can override the _DEBUG and _DEBUG_DECIMAL macros.

Notes:

  1. When assertion checking is on, the _DecimalT template-class constant and parameters of the _DecimalT class template are validated.

  2. Checking for divide-by-zero, overflow, and truncation in the _DecimalT template-class digit is hard-coded in the C++ run-time libraries and cannot be turned off by the _NODEBUG_DECIMAL macro.

  3. You can use the _DEBUG macro to turn assertion checking on for the _DecimalT class template. If you are already using the _DEBUG macro in your source, you can use the _DEBUG_DECIMAL macro to turn on assertion checking, for the _DecimalT class template only.

Enabling and Disabling Error Checking for the _DecimalT Class Template

To enable error checking within the _DecimalT class template, you can turn on the debug macro by adding either the DEFINE(_DEBUG_DECIMAL) option or the DEFINE(_DEBUG) option during the invocation of the compiler, as shown in the following figure.

Figure 310. Commands to Enable Error Checking within the _DecimalT Class Template at Compile Time



CRTCPPMOD DEFINE(_DEBUG)
CRTBNDCPP DEFINE(_DEBUG)
CRTCPPMOD DEFINE(_DEBUG_DECIMAL)
CRTBNDCPP DEFINE(_DEBUG_DECIMAL)

Notes:

  1. The difference between the _D_DEBUG and _D_DEBUG_DECIMAL invocations depends on whether or not the _DEBUG macro is used by other classes to control the error checking. If the _DEBUG macro is used by another class, DEFINE(_DEBUG) affects all classes that use the _DEBUG macro and DEFINE(_DEBUG_DECIMAL) affects only the _DecimalT class template.

  2. When you turn assertion checking on for a group of files using the _DEBUG macro, use the _NODEBUG_DECIMAL macro to override the _DEBUG macro and turn assertion checking off for the _DecimalT class template.

To disable error checking within the _DecimalT class template, you can use the commands shown in the following figure:

Figure 311. Commands to Disable Error Checking within the _DecimalT Class Template at Compile Time



CRTCPPMOD DEFINE('_D_DEBUG_DECIMAL temp.cpp')
CRTBNDCPP DEFINE('_D_DEBUG_DECIMAL temp.cpp')

CRTCPPMOD DEFINE('_D_NODEBUG_DECIMAL temp.cpp') //This is the default.
CRTBNDCPP DEFINE('_D_NODEBUG_DECIMAL temp.cpp') //This is the default.

Notes:

  1. You can enable error checking for all classes, except the _DecimalT class template, that use _DEBUG as the control macro by using one of the following commands:
    CRTCPPMOD DEFINE('_D_DEBUG_DECIMAL temp.cpp')
    CRTBNDCPP DEFINE('_D_DEBUG_DECIMAL temp.cpp')
    

  2. If you try to use both the _DEBUG_DECIMAL and _NODEBUG_DECIMAL macros on the same invocation, the _NODEBUG_DECIMAL macro takes precedence, and error checking for the _DecimalT class template is disabled.


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