mirror of
https://github.com/fmtlib/fmt.git
synced 2025-11-30 22:29:23 +01:00
Add FMT_HAS_CPP14_ATTRIBUTE / FMT_HAS_CPP17_ATTRIBUTE to test for language-specific attributes.
FMT_DEPRECATED is now defined as FMT_HAS_CPP14_ATTRIBUTE(deprecated), as this attribute was introduced in C++14. FMT_FALLTHROUGH is now defined as FMT_HAS_CPP17_ATTRIBUTE(fallthrough), as this attribute was introduced in C++17. FMT_MAYBE_UNUSED is defined as FMT_HAS_CPP17_ATTRIBUTE(maybe_unused), as this attribute was introduced in C++17. FMT_MAYBE_UNUSED has been applied to fix a couple of -Wunused-member-function warnings from clang.
This commit is contained in:
committed by
Victor Zverovich
parent
3c24052cf1
commit
02bfd8a9a5
@@ -36,6 +36,12 @@
|
||||
# define FMT_HAS_CPP_ATTRIBUTE(x) 0
|
||||
#endif
|
||||
|
||||
#define FMT_HAS_CPP14_ATTRIBUTE(attribute) \
|
||||
(__cplusplus >= 201402L && FMT_HAS_CPP_ATTRIBUTE(attribute))
|
||||
|
||||
#define FMT_HAS_CPP17_ATTRIBUTE(attribute) \
|
||||
(__cplusplus >= 201703L && FMT_HAS_CPP_ATTRIBUTE(attribute))
|
||||
|
||||
#ifdef __clang__
|
||||
# define FMT_CLANG_VERSION (__clang_major__ * 100 + __clang_minor__)
|
||||
#else
|
||||
@@ -132,9 +138,16 @@
|
||||
# define FMT_NORETURN
|
||||
#endif
|
||||
|
||||
#ifndef FMT_MAYBE_UNUSED
|
||||
# if FMT_HAS_CPP17_ATTRIBUTE(maybe_unused)
|
||||
# define FMT_MAYBE_UNUSED [[maybe_unused]]
|
||||
# else
|
||||
# define FMT_MAYBE_UNUSED
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef FMT_DEPRECATED
|
||||
# if (FMT_HAS_CPP_ATTRIBUTE(deprecated) && __cplusplus >= 201402L) || \
|
||||
FMT_MSC_VER >= 1900
|
||||
# if FMT_HAS_CPP14_ATTRIBUTE(deprecated) || FMT_MSC_VER >= 1900
|
||||
# define FMT_DEPRECATED [[deprecated]]
|
||||
# else
|
||||
# if defined(__GNUC__) || defined(__clang__)
|
||||
|
||||
Reference in New Issue
Block a user