#pragma once #include #include struct X { #ifdef LOG_DEBUG X() { if(false) std::cout.setstate(std::ios_base::failbit); } ~X() { if(false) { std::cout.clear(); } else { std::cout << std::endl << std::flush; } } #else X() { std::cout.setstate(std::ios_base::failbit); } ~X() { std::cout.clear(); } #endif }; #define DEBUG (X(), std::cout << "DEBUG[" << __FILENAME__ << ":" << __LINE__ << " in " << __func__ << "()]: ") #define WARN (X(), std::cout << "WARN [" << __FILENAME__ << ":" << __LINE__ << " in " << __func__ << "()]: ") #ifdef LOG_DEBUG #define STEP \ do { DEBUG << "Stepping through, Hit Enter..."; \ std::cin.get(); \ } while (0) #else #define STEP (void)(0) #endif namespace io { void debug(std::string msg); }