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

call to non-constexpr function #1811

Closed
854768750 opened this issue Jan 21, 2021 · 2 comments
Closed

call to non-constexpr function #1811

854768750 opened this issue Jan 21, 2021 · 2 comments

Comments

@854768750
Copy link

854768750 commented Jan 21, 2021

After I pull the latest spdlog and recompile it, my code cannot compile.
/opt/spdlog/include/spdlog/common-inl.h:16:43: error: call to non-constexpr function 'fmt::v7::basic_string_view<Char>::basic_string_view(const Char*) [with Char = char]' static string_view_t level_string_views[] SPDLOG_LEVEL_NAMES;

And I checkout to the commit before #1798, there is no error. Does this pull request cause the problem? @gv-me
Even something like logger->info("{0}",idx); connot pass the compilation where idx is an int.

@gv-me
Copy link
Contributor

gv-me commented Jan 21, 2021

are you using C++11 or older? And are you using compiled or header only version or spdlog? Please give the full error output.

I suspect this could be coming from constructor fmt::basic_string_view(const Char* s) in fmt/core.h:380.
This is conditionally made constexpr by fmt for C++>=17 where it could have been made from C++ >= 14 in which the required constexpr features were made available. So this could be a potential issue for C++ 14 users.

Ideally the flags should be changed in fmt function declarations. If you switch to C++ 17 this will not be a problem.
If you must use C++14, as a workaround you can change the #if __cplusplus >= 201402L at line 13 in common-inl.h to #if __cplusplus >= 201703L and see if it works.

@854768750
Copy link
Author

change the #if __cplusplus >= 201402L at line 13 in common-inl.h to #if __cplusplus >= 201703L works. Thank you.

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