Skip to content

Commit

Permalink
Extend FMT_FALLTHROUGH compatibily to gcc and clang pre-C++17 (#1469)
Browse files Browse the repository at this point in the history
  • Loading branch information
federico-busato authored and vitaut committed Dec 11, 2019
1 parent 7abec07 commit b272fb3
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions include/fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,17 @@
# define FMT_HAS_BUILTIN(x) 0
#endif

#if FMT_HAS_CPP_ATTRIBUTE(fallthrough) && \
(__cplusplus >= 201703 || FMT_GCC_VERSION != 0)
# define FMT_FALLTHROUGH [[fallthrough]]
#if __cplusplus == 201103L || __cplusplus == 201402L
# if defined(__clang__)
# define FMT_FALLTHROUGH [[clang::fallthrough]];
# elif FMT_GCC_VERSION >= 700
# define FMT_FALLTHROUGH [[gnu::fallthrough]];
# else
# define FMT_FALLTHROUGH
# endif
#elif FMT_HAS_CPP_ATTRIBUTE(fallthrough) && \
((__cplusplus >= 201703) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L))
# define FMT_FALLTHROUGH [[fallthrough]];
#else
# define FMT_FALLTHROUGH
#endif
Expand Down

0 comments on commit b272fb3

Please sign in to comment.