TBCI Numerical high perf. C++ Library  2.8.0
Error check macros

For error checking in the TBCI library, the macros BCHK and BCHKNR and EXPCHK and EXPCHKNR are used.

The variants without NR do return a return value to the caller. The macros with EXP are meant for expensive error checking and are disabled by default. (Change this with TBCI_EXPCHECK.)

If the library is compiled with TBCI_NO_ERRCHECK, no checking will be done.

Otherwise, their behaviour depends on the TBCI configuration (see tbci_param.h). The relevant settings here are errcheck: error checking enabled (default: yes) expcheck: do expensive error checks (default: no) abort: call abort() on error (default: no) Useful mainly when using a debugger (gdb) except: throw an exception on error (default: yes) All TBCI exceptions are derived from TBCI::NumErr.

Parameters
cond- condition to check. Should evaluate to true, if there is an error
exc- exception to be thrown
txt- text to be printed (or stored in TBCI::NumErr::errtext)
ind- index to print (or store in TBCI::NumErr::index) in case of out-of-bound errors
rtval- value to return to caller

Implementation note: Normally, the do_errcheck() / do_expcheck() should be tested before the error condition, assuming that the determination of the err checking status is cheap. Unfortunately, this turns out not to be the case when using the singleton construction in tbci_param.h. Thus bite the bullet and introduce a global variable. The global var is defined in smp.cc – but that's no strong reasons to link it (if there's no other reasons to do so anyway); just defining a global var namespace TBCI { unsigned int tbci_control = _TBCI_CWD_DEFAULT; }; will do the job. These macros are not currently prepared to handle the case where exceptions have been disabled by the preprocessor (TBCI_DISABLE_EXCEPT)