-
Notifications
You must be signed in to change notification settings - Fork 48
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
build fails due to fmt::format being consteval on C++20 #492
Comments
Hmm, this is strange. We are asking cmake to build with the C++17 standard: Line 90 in 7085e98
The error above occurs during the compilation of Might be that |
Yeap! This fixes it:
Thanks! |
Sorry, but now I'm getting linking errors due to fmt and chemfiles conflicting. Something like this:
Will trigger linking errors from
Apparently this file is only used when fmtlib is used in header-only format:
But I'm pretty sure I'm not doing that and neither does chemfiles. Maybe it's the way I'm getting both libraries, I'm using CPM to get the packages directly from github. Have you ever run into anything like this? |
So I was trying to prevent this kind of issue by making all the symbols hidden: https://github.com/chemfiles/fmt/blob/6fc2a95218a50f69d8d54629645bf954e4ed89bb/0-chemfiles/CMakeLists.txt#L15-L16 But there might be something wrong here. Does it work if you build chemfiles as a shared library? I'm not sure how static libraries handle hidden symbols. Another workaround might be to only build
What's CPM? |
Generating a shared library actually fixes it, thanks again. CPM is like Now I'm just including the chemfiles dir along my project. with Thank you again for your help. |
Hi!
I have a C++20 project and I was getting these errors when compiling against chemfiles with C++20:
switching the standard to C++17 fixed the issue.
To confirm this, I cloned chemfiles and built from source using different configuration steps:
Apparently
fmt::format
is consteval since C++20 and expects a constant expression in the format string.Solutions I can think of
const char *
inerror_fmt.hpp
andwarnings.hpp
withfmt::format_string<Args...>
which does work since the library is indeed sending strings known at compile time each time it uses these error and warning functions. This one does work, but it's a break for users that are using chemfiles error functions and sending them runtime strings.const char *
andfmt::format_string<Args...>
.fmt::format
withfmt::vformat
, that does work with runtime strings. The drawback is that you loose compile-time check of the format string.Some extra references:
The text was updated successfully, but these errors were encountered: