|Delphi Clinic||C++Builder Gate||Training & Consultancy||Delphi Notes Weblog||Dr.Bob's Webshop|
This is the first installment of lost+found. In this series I will discuss small problems, little gems and other stuff that I stumble on to. Have fun.
Recently somebody complained about the fact that a program that had a custom error handler for mathematical errors did not compile anymore. Upon trying the example program that came with the _matherr and _matherrl documentation I initially got the same results. Consultation of the RTL source and <math.h> soon gave me the insight that since C++ defines an 'exception' class in the standard C++ library that there is a name conflict with the typenames of the arguments passed to _matherr and _matherrl:
int _matherr(struct exception* e);
int _matherrl(struct exceptionl* e);
In <math.h> a #define is used to circumvent such conflicts, therefore, when compiling a C++ program that uses this construct to handle math errors, you must write instead of the above:
int matherr(struct math_exception* e);
int matherrl(struct math_exceptionl* e);
This solves any name conflicts with types in the Standard C++ Library and the 'regular' C runtime library.