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
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions include/spdlog/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,21 @@
#if defined(_MSC_VER) && (_MSC_VER < 1900)
# define SPDLOG_NOEXCEPT _NOEXCEPT
# define SPDLOG_CONSTEXPR
# define SPDLOG_CONSTEXPR_FUNC inline
#else
# define SPDLOG_NOEXCEPT noexcept
# define SPDLOG_CONSTEXPR constexpr
# if __cplusplus >= 201402L
# define SPDLOG_CONSTEXPR_FUNC constexpr
# else
# define SPDLOG_CONSTEXPR_FUNC inline
# endif
#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.

#endif

#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.

# define SPDLOG_CONSTEXPR_FUNC constexpr
#else
# define SPDLOG_CONSTEXPR_FUNC inline
#endif

#if defined(__GNUC__) || defined(__clang__)
Expand Down