From 2b46c9e3ab2add6f0e3075ba9ee31b7040ee0ae2 Mon Sep 17 00:00:00 2001 From: servostar Date: Sun, 14 Apr 2024 17:09:28 +0200 Subject: [PATCH] added custom define for macro `__FILE_NAME__` for non supporting compilers --- src/sys/log.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/sys/log.h b/src/sys/log.h index 84d0440..f582eb9 100644 --- a/src/sys/log.h +++ b/src/sys/log.h @@ -3,6 +3,7 @@ #include #include +#include #define LOG_DEFAULT_STREAM stderr @@ -20,6 +21,16 @@ #define LOG_STRING_INFORMATION "Information" #define LOG_STRING_DEBUG "Debug" +// define __FILE_NAME__ macro if not defined +// generally not defined by GCC < 11.3 and MSVC +#ifndef __FILE_NAME__ +#if defined(_WIN32) || defined(_WIN64) || defined(_MSC_VER) +#define __FILE_NAME__ (strrstr(__FILE__, "\\\\") ? strrstr(__FILE__, "\\\\") + 1 : __FILE__) +#else +#define __FILE_NAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__) +#endif +#endif + /** * @brief Panic is used in cases where the process is in an unrecoverable state. * This macro will print debug information to stderr and call abort() to