diff --git a/src/Exception.hpp b/src/Exception.hpp index 3fabf2b..4b7e9f5 100644 --- a/src/Exception.hpp +++ b/src/Exception.hpp @@ -140,12 +140,21 @@ namespace ArbUt { }; } -#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__) +static constexpr const char* file_name(const char* path) { + const char* file = path; + while (*path) { + if (*path++ == '/') { + file = path; + } + } + return file; +} #define THROW(message) \ std::stringstream ___ss; \ - ___ss << "[" << __FILENAME__ << ":" << __LINE__ << "] " << message; \ + ___ss << "[" << file_name(__FILE__) << ":" << __LINE__ << "] " << (message); \ throw ArbUt::Exception(___ss.str()); + #define NOT_REACHABLE THROW("Not reachable"); #define NOT_IMPLEMENTED THROW("Not implemented");