Use __has_cpp_attribute for NOWIDE_FALLTHROUGH

This commit is contained in:
Luke Street 2021-06-30 16:22:27 -04:00
parent 6eadd55f7a
commit 4f7f3f2147
1 changed files with 8 additions and 2 deletions

View File

@ -58,8 +58,14 @@
#define NOWIDE_USE_FILEBUF_REPLACEMENT 0
#endif
#if defined(__GNUC__) && __GNUC__ >= 7
#define NOWIDE_FALLTHROUGH __attribute__((fallthrough))
#if defined(__has_cpp_attribute)
#define NOWIDE_HAS_CPP_ATTRIBUTE(attr) __has_cpp_attribute(attr)
#else
#define NOWIDE_HAS_CPP_ATTRIBUTE(attr) (0)
#endif
#if NOWIDE_HAS_CPP_ATTRIBUTE(fallthrough)
#define NOWIDE_FALLTHROUGH [[fallthrough]]
#else
#define NOWIDE_FALLTHROUGH
#endif