Open
Description
I want to use gettext for internationalization support, my code is as follows:
std::string world = "World";
SPDLOG_INFO(boost::locale::gettext("Hello {}"), world);
When I compile, the following error is reported. It seems that the first argument to the SPDLOG_INFO macro does not support strings computed at runtime. What should I do?
In file included from /tmp/develop/linux_agent/src/main.cpp:67:
/tmp/develop/linux_agent/src/main.cpp: In function ‘int main(int, const char**)’:
/tmp/develop/linux_agent/thirdparty/spdlog/include/spdlog/spdlog.h:288:22: error: call to non-‘constexpr’ function ‘std::__cxx11::basic_string<_CharT> boost::locale::gettext(const CharType*, const std::locale&) [with CharType = char]’
288 | (logger)->log(spdlog::source_loc{__FILE__, __LINE__, SPDLOG_FUNCTION}, level, __VA_ARGS__)
| ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/develop/linux_agent/thirdparty/spdlog/include/spdlog/spdlog.h:314:9: note: in expansion of macro ‘SPDLOG_LOGGER_CALL’
314 | SPDLOG_LOGGER_CALL(logger, spdlog::level::info, __VA_ARGS__)
| ^~~~~~~~~~~~~~~~~~
/tmp/develop/linux_agent/thirdparty/spdlog/include/spdlog/spdlog.h:315:30: note: in expansion of macro ‘SPDLOG_LOGGER_INFO’
315 | #define SPDLOG_INFO(...) SPDLOG_LOGGER_INFO(spdlog::default_logger_raw(), __VA_ARGS__)
| ^~~~~~~~~~~~~~~~~~
/tmp/develop/linux_agent/src/main.cpp:357:5: note: in expansion of macro ‘SPDLOG_INFO’
357 | SPDLOG_INFO(boost::locale::gettext("Hello {}"), world);
| ^~~~~~~~~~~
In file included from /usr/include/boost/locale/format.hpp:13,
from /usr/include/boost/locale.hpp:16,
from /tmp/develop/linux_agent/src/common/localization.hpp:4,
from /tmp/develop/linux_agent/src/main.cpp:65:
/usr/include/boost/locale/message.hpp:432:33: note: ‘std::__cxx11::basic_string<_CharT> boost::locale::gettext(const CharType*, const std::locale&) [with CharType = char]’ declared here
432 | std::basic_string<CharType> gettext(const CharType* id, const std::locale& loc = std::locale())
| ^~~~~~~
Metadata
Metadata
Assignees
Labels
No labels