mirror of
https://github.com/fmtlib/fmt.git
synced 2025-07-30 02:37:36 +02:00
Make MSVC use [[nodiscard]] (#2615)
* Make MSVC use [[nodiscard]] * Uniformly detect attributes for __cplusplus and _MSVC_LANG
This commit is contained in:
@ -82,11 +82,17 @@
|
|||||||
# define FMT_HAS_CPP_ATTRIBUTE(x) 0
|
# define FMT_HAS_CPP_ATTRIBUTE(x) 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef _MSVC_LANG
|
||||||
|
# define FMT_CPLUSPLUS _MSVC_LANG
|
||||||
|
#else
|
||||||
|
# define FMT_CPLUSPLUS __cplusplus
|
||||||
|
#endif
|
||||||
|
|
||||||
#define FMT_HAS_CPP14_ATTRIBUTE(attribute) \
|
#define FMT_HAS_CPP14_ATTRIBUTE(attribute) \
|
||||||
(__cplusplus >= 201402L && FMT_HAS_CPP_ATTRIBUTE(attribute))
|
(FMT_CPLUSPLUS >= 201402L && FMT_HAS_CPP_ATTRIBUTE(attribute))
|
||||||
|
|
||||||
#define FMT_HAS_CPP17_ATTRIBUTE(attribute) \
|
#define FMT_HAS_CPP17_ATTRIBUTE(attribute) \
|
||||||
(__cplusplus >= 201703L && FMT_HAS_CPP_ATTRIBUTE(attribute))
|
(FMT_CPLUSPLUS >= 201703L && FMT_HAS_CPP_ATTRIBUTE(attribute))
|
||||||
|
|
||||||
// Check if relaxed C++14 constexpr is supported.
|
// Check if relaxed C++14 constexpr is supported.
|
||||||
// GCC doesn't allow throw in constexpr until version 6 (bug 67371).
|
// GCC doesn't allow throw in constexpr until version 6 (bug 67371).
|
||||||
@ -180,8 +186,7 @@
|
|||||||
# else
|
# else
|
||||||
# define FMT_FALLTHROUGH
|
# define FMT_FALLTHROUGH
|
||||||
# endif
|
# endif
|
||||||
#elif FMT_HAS_CPP17_ATTRIBUTE(fallthrough) || \
|
#elif FMT_HAS_CPP17_ATTRIBUTE(fallthrough)
|
||||||
(defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)
|
|
||||||
# define FMT_FALLTHROUGH [[fallthrough]]
|
# define FMT_FALLTHROUGH [[fallthrough]]
|
||||||
#else
|
#else
|
||||||
# define FMT_FALLTHROUGH
|
# define FMT_FALLTHROUGH
|
||||||
|
Reference in New Issue
Block a user