diff --git a/include/wjr/preprocessor/preview.hpp b/include/wjr/preprocessor/preview.hpp index 41529985..40a03f84 100644 --- a/include/wjr/preprocessor/preview.hpp +++ b/include/wjr/preprocessor/preview.hpp @@ -51,14 +51,14 @@ template , int> = 0> WJR_COLD WJR_NOINLINE void __assert_fail(const char *expr, const char *file, int line, Handler handler, Args &&...args) { - fprintf(stderr, "Assertion failed: %s", expr); - if (file != nullptr && file[0] != '\0') { - fprintf(stderr, ", file %s", file); + (void)fprintf(stderr, "Assertion failed: %s", expr); + if ((file != nullptr) && (file[0] != '\0')) { + (void)fprintf(stderr, ", file %s", file); } if (line != -1) { - fprintf(stderr, ", line %d", line); + (void)fprintf(stderr, ", line %d", line); } - fprintf(stderr, "\n"); + (void)fprintf(stderr, "\n"); __assert_fail(handler, std::forward(args)...); } @@ -67,9 +67,9 @@ struct __assert_t { template void operator()(const char *fmt, Args &&...args) { - fprintf(stderr, "Additional message: "); - fprintf(stderr, fmt, std::forward(args)...); - fprintf(stderr, "\n"); + (void)fprintf(stderr, "Additional message: "); + (void)fprintf(stderr, fmt, std::forward(args)...); + (void)fprintf(stderr, "\n"); } }; @@ -77,8 +77,8 @@ inline constexpr __assert_t __assert{}; #define WJR_ASSERT_NOMESSAGE_FAIL(handler, exprstr) \ __assert_fail(exprstr, WJR_FILE, WJR_LINE, handler) -#define WJR_ASSERT_MESSAGE_FAIL(handler, exprstr, fmt, ...) \ - __assert_fail(exprstr, WJR_FILE, WJR_LINE, handler, fmt, ##__VA_ARGS__) +#define WJR_ASSERT_MESSAGE_FAIL(handler, exprstr, ...) \ + __assert_fail(exprstr, WJR_FILE, WJR_LINE, handler, __VA_ARGS__) #define WJR_ASSERT_CHECK_I_NOMESSAGE(handler, expr) \ do { \ @@ -86,10 +86,10 @@ inline constexpr __assert_t __assert{}; WJR_ASSERT_NOMESSAGE_FAIL(handler, #expr); \ } \ } while (0) -#define WJR_ASSERT_CHECK_I_MESSAGE(handler, expr, fmt, ...) \ +#define WJR_ASSERT_CHECK_I_MESSAGE(handler, expr, ...) \ do { \ if (WJR_UNLIKELY(!(expr))) { \ - WJR_ASSERT_MESSAGE_FAIL(handler, #expr, fmt, ##__VA_ARGS__); \ + WJR_ASSERT_MESSAGE_FAIL(handler, #expr, __VA_ARGS__); \ } \ } while (0) @@ -125,11 +125,12 @@ inline constexpr __assert_t __assert{}; // level of assert is zero at default. #define WJR_ALWAYS_ASSERT(...) WJR_ALWAYS_ASSERT_L(0, __VA_ARGS__) -#define WJR_ASSERT_ASSUME_L(level, expr, ...) \ - WJR_ASSERT_L(level, expr, ##__VA_ARGS__); \ - WJR_ASSUME(expr) +#define WJR_ASSERT_ASSUME_L(level, ...) \ + WJR_ASSERT_L(level, __VA_ARGS__); \ + __WJR_ASSERT_ASSUME_L_ASSUME(__VA_ARGS__) +#define __WJR_ASSERT_ASSUME_L_ASSUME(expr, ...) WJR_ASSUME(expr) -#define WJR_ASSERT_ASSUME(expr, ...) WJR_ASSERT_ASSUME_L(0, expr, ##__VA_ARGS__) +#define WJR_ASSERT_ASSUME(...) WJR_ASSERT_ASSUME_L(0, __VA_ARGS__) // (a, b, c) -> f(a) f(b) f(c) #define WJR_PP_TRANSFORM_PUT(queue, op) \ diff --git a/include/wjr/span.hpp b/include/wjr/span.hpp index 596291df..1c900828 100644 --- a/include/wjr/span.hpp +++ b/include/wjr/span.hpp @@ -16,7 +16,9 @@ struct __span_static_storage { __span_static_storage(const __span_static_storage &) = default; __span_static_storage &operator=(const __span_static_storage &) = default; - __span_static_storage(T *p, size_t s) : ptr(p) { WJR_ASSERT(s == size); } + __span_static_storage(T *p, WJR_MAYBE_UNUSED size_t s) : ptr(p) { + WJR_ASSERT(s == size); + } T *ptr = nullptr; static constexpr size_t size = Extent; diff --git a/include/wjr/stack_allocator.hpp b/include/wjr/stack_allocator.hpp index aa2e7bbb..b71bfba4 100644 --- a/include/wjr/stack_allocator.hpp +++ b/include/wjr/stack_allocator.hpp @@ -79,7 +79,7 @@ class stack_alloc { } WJR_NODISCARD WJR_CONSTEXPR20 void *allocate(size_t n) { - if (WJR_UNLIKELY(m_node.end - m_node.ptr < n)) { + if (WJR_UNLIKELY(static_cast(m_node.end - m_node.ptr) < n)) { if (WJR_LIKELY(m_idx != -1ull)) { m_stk[m_idx].ptr = m_node.ptr; @@ -98,7 +98,7 @@ class stack_alloc { return ret; } - WJR_CONSTEXPR20 void deallocate(void *ptr, size_t n) { + WJR_CONSTEXPR20 void deallocate(void *ptr, WJR_MAYBE_UNUSED size_t n) { WJR_ASSERT(m_node.ptr == static_cast(ptr) + n); m_node.ptr = static_cast(ptr);