Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error using std::to_hex() when compiled with MSVC #2473

Closed
chaarirami opened this issue Aug 30, 2022 · 2 comments
Closed

Error using std::to_hex() when compiled with MSVC #2473

chaarirami opened this issue Aug 30, 2022 · 2 comments

Comments

@chaarirami
Copy link

Calling

std::vector<uint8_t> payloadArray(payload.buffer, payload.buffer + payload.len);
spdlog::info("Received payload from topic {}: {:n}", topic, spdlog::to_hex(std::begin(payloadArray), std::end(payloadArray)));

yields the following error:

error C3615: constexpr function 'fmt::v8::detail::parse_format_specs' cannot result in a constant expression
/fmt/bundled/core.h(2675,17): message : failure was caused by call of undefined function or one not declared 'constexpr' 
message : see usage of 'fmt::v8::formatter<spdlog::details::dump_info<std::_Vector_iterator<std::_Vector_val<std::_Simple_types<_Ty>>>>,char,void>::parse' 
          with
          [
              _Ty=uint8_t
          ]

Any suggestion on how to fix this error?
Thank you for your help.

@tt4g
Copy link
Contributor

tt4g commented Aug 30, 2022

I think this is fmt library issue. Maybe related fmtlib/fmt#2761

Is the workaround fmt::runtime() work?

#2430 (comment)

It appears to be a problem with the fmt library or the clang compiler fmtlib/fmt#2455.
Does this workaround fmtlib/fmt#2438 not work?

@chaarirami
Copy link
Author

Thanks, I was able to fix the issue using

spdlog::info(fmt::runtime("Received payload from topic {}: {:n}"), topic, spdlog::to_hex(std::begin(receivedPayload), std::end(receivedPayload)));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants