From c1c3e87444baab0e32dc91b562b21542c0148578 Mon Sep 17 00:00:00 2001 From: Adwaith-Rajesh Date: Sun, 28 Sep 2025 12:34:05 +0530 Subject: [PATCH] block -> va_args having them as blocks causes issues when a struct with values is initialized inside the block, because the compiler treats the comma in the struct defenition as seperate arguments. --- test.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test.h b/test.h index 6601e7b..c8cc564 100644 --- a/test.h +++ b/test.h @@ -36,7 +36,7 @@ static test_func_t test_functions[MAX_TEST_FUNCS]; return (failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; \ } -#define TEST(NAME, BLOCK) \ +#define TEST(NAME, ...) \ static int test_##NAME(); \ __attribute__((constructor)) static void register_test_##NAME() { \ if (total < MAX_TEST_FUNCS) { \ @@ -50,7 +50,7 @@ static test_func_t test_functions[MAX_TEST_FUNCS]; printf("\ntest_" #NAME "\n"); \ int total_assert = 0; \ int total_success = 0; \ - BLOCK \ + __VA_ARGS__ \ printf("\t(%d/%d) passed (%d) failed\n", total_success, total_assert, total_assert - total_success); \ return (total_assert == total_success); \ }