#define SPDLOG_LEVEL_NAMES with external FMT doesn't compile, starting from libfmt11.
This came up macOS/apple clang:
In file included from /opt/local/include/spdlog/common.h:410:
/opt/local/include/spdlog/common-inl.h:19:26: error: constexpr variable 'level_string_views' must be initialized by a constant expression
static string_view_t level_string_views[] SPDLOG_LEVEL_NAMES;
^ ~~~~~~~~~~~~~~~~~~
/opt/local/include/spdlog/common-inl.h:19:47: note: non-constexpr constructor 'basic_string_view' cannot be used in a constant expression
static string_view_t level_string_views[] SPDLOG_LEVEL_NAMES;
^
/Users/Koji/performous/game/log.hh:11:30: note: expanded from macro 'SPDLOG_LEVEL_NAMES'
#define SPDLOG_LEVEL_NAMES { "TRACE", "DEBUG", "INFO", "NOTICE", "WARNING", "ERROR", "OFF" }
^
/opt/local/include/libfmt11/fmt/base.h:536:3: note: declared here
basic_string_view(const Char* s)
^
Removing the constexpr from static string_view_t level_string_views[] SPDLOG_LEVEL_NAMES; makes it compile, but I don't think this is really the correct fix?
This is working, and at least is a better work-around IMO:
#include <string_view>
using namespace std::string_view_literals;
#define SPDLOG_LEVEL_NAMES { "TRACE"sv, "DEBUG"sv, "INFO"sv, "NOTICE"sv, "WARNING"sv, "ERROR"sv, "OFF"sv }
PR is welcome. Note that the “sv” literal is c++17 while spdlog should support 11
PR is welcome. Note that the “sv” literal is c++17 while spdlog should support 11
I would open a PR, but I don't really know what the best approach is for the majority of people.
PR is welcome. Note that the “sv” literal is c++17 while spdlog should support 11
I was thinking again on this and realized that this would likely not really be an issue, because the problem only presents when level_string_views[] is declared constexpr and that is gated under a check for c++17 already.
So, most likely for now at least the only thing you really need to change is documenting this option, which could likely be done in the same tweakme header
PR is welcome. Note that the “sv” literal is c++17 while spdlog should support 11
I was thinking again on this and realized that this would likely not really be an issue, because the problem only presents when
level_string_views[]is declaredconstexprand that is gated under a check for c++17 already.So, most likely for now at least the only thing you really need to change is documenting this option, which could likely be done in the same
tweakmeheader
I encountered this issue while compiling the project using C++ 17, and after switching the C++ version to 14 or 20, the compilation was successful.