#include #include #include #if defined(__APPLE__) #include #endif #include #include #include // include my project macros before I see Boost Units // this defines BOOST_SIGNALING_NAN // comment this out to disable signaling nan #include "project_macros.hpp" // this includes quantity.hpp // this only defines BOOST_SIGNALING_NAN_ENABLED if // this version of Boost Units quantity.hpp has support // for BOOST_SIGNALING_NAN #include "boost/units/quantity.hpp" #include "boost/units/systems/si/acceleration.hpp" using std::numeric_limits; using std::runtime_error; using std::string; void nan_signal_handler(int) { void *array[100]; size_t size = backtrace(array, 10); char **strings = backtrace_symbols(array, size); string s = "\nError: memory initialized to signaling NaN was accessed\n"; for (size_t i=0; i::signaling_NaN(); typedef quantity acceleration_t; // this quantity has been initialized to signaling nan // if BOOST_SIGNALING_NAN_ENABLED is defined acceleration_t a; #if defined(BOOST_SIGNALING_NAN_ENABLED) // this will trigger the SIGFPE signal handler a *= 5; #else // this will not trigger the SIGFPE signal handler a *= 5; #endif return 0; }