Unified · Split
| @@ -3,21 +3,30 @@ · 2 unmodified lines | ||
| 3 | 3 | |
| 4 | 4 | #define MP_EXPAND_ARGS(...) __VA_ARGS__ |
| 5 | 5 | |
| 6 | −#if defined(__GNUC__) || defined(__clang__) | |
| 7 | −#define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format(printf, a1, a2))) | |
| 8 | −#define SCANF_ATTRIBUTE(a1, a2) __attribute__ ((format(scanf, a1, a2))) | |
| 6 | +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L | |
| 7 | +#define MP_NORETURN [[noreturn]] | |
| 8 | +#define MP_FALLTHROUGH [[fallthrough]] | |
| 9 | +#define MP_WARN_UNUSED_RESULT [[nodiscard]] | |
| 10 | +#define MP_UNUSED [[maybe_unused]] | |
| 11 | +#elif defined(__GNUC__) || defined(__clang__) | |
| 9 | 12 | #define MP_NORETURN __attribute__((noreturn)) |
| 10 | 13 | #define MP_FALLTHROUGH __attribute__((fallthrough)) |
| 11 | 14 | #define MP_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) |
| 12 | 15 | #define MP_UNUSED __attribute__((unused)) |
| 13 | −#define MP_ASSERT_UNREACHABLE() (assert(!"unreachable"), __builtin_unreachable()) | |
| 14 | 16 | #else |
| 15 | −#define PRINTF_ATTRIBUTE(a1, a2) | |
| 16 | −#define SCANF_ATTRIBUTE(a1, a2) | |
| 17 | 17 | #define MP_NORETURN |
| 18 | 18 | #define MP_FALLTHROUGH do {} while (0) |
| 19 | 19 | #define MP_WARN_UNUSED_RESULT |
| 20 | 20 | #define MP_UNUSED |
| 21 | +#endif | |
| 22 | + | |
| 23 | +#if defined(__GNUC__) || defined(__clang__) | |
| 24 | +#define PRINTF_ATTRIBUTE(a1, a2) __attribute__((format(printf, a1, a2))) | |
| 25 | +#define SCANF_ATTRIBUTE(a1, a2) __attribute__((format(scanf, a1, a2))) | |
| 26 | +#define MP_ASSERT_UNREACHABLE() (assert(!"unreachable"), __builtin_unreachable()) | |
| 27 | +#else | |
| 28 | +#define PRINTF_ATTRIBUTE(a1, a2) | |
| 29 | +#define SCANF_ATTRIBUTE(a1, a2) | |
| 21 | 30 | #define MP_ASSERT_UNREACHABLE() (assert(!"unreachable"), abort()) |
| 22 | 31 | #endif |
| 23 | 32 | |