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

Modify the condition of SPDLOG_CONSTEXPR_FUNC to match that of fmt #2859

Closed
wants to merge 1 commit into from

Conversation

ShujianQian
Copy link

fix the issue where constexpr function in spdlog may call non-constexpr function in the bundled fmt because FMT_USE_CONSTEXPR is not defined.

fix #2856

fix the issue where constexpr function in spdlog may call non-constexpr function in the bundled fmt because FMT_USE_CONSTEXPR is not defined.
#endif

#ifndef __has_feature
# define __has_feature(x) 0
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't define standard macros, even if to 0. It will surely break users code.


#if (__has_feature(cxx_relaxed_constexpr) || (defined(_MSC_VER) && (_MSC_VER >= 1912)) || \
(defined(__GNUC__) && __GNUC__ >= 6 && defined(__cplusplus) && __cplusplus >= 201402L)) && \
!defined(__ICL) && !defined(__INTEL_COMPILER) && !defined(__NVCC__)
Copy link
Owner

@gabime gabime Aug 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be simplified greatly. No need to check the defined(..), only the comparisons since undefined macro values equal to 0. See https://stackoverflow.com/questions/5085392/what-is-the-value-of-an-undefined-constant-used-in-if

Also please add comment describing the purpose of those checks.It will be hard to understand why without description.

@kkraus14
Copy link
Contributor

This seemed stale so I have created a new PR based on this PR to try to help it over the finish line: #2901

@gabime gabime closed this Mar 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants