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