From: Arran Cudbard-Bell Date: Thu, 30 Jan 2020 20:14:46 +0000 (-0500) Subject: acutest needs to work with compilers other than gcc and clang X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a2e2204d4b35f5b935abe8975dab2c96a0dbc968;p=thirdparty%2Ffreeradius-server.git acutest needs to work with compilers other than gcc and clang --- diff --git a/src/lib/util/acutest.h b/src/lib/util/acutest.h index 1c12a199eb2..c60416864fa 100644 --- a/src/lib/util/acutest.h +++ b/src/lib/util/acutest.h @@ -285,6 +285,12 @@ #endif #endif +/* Enable the use of the non-standard keyword CC_ATTRIBUTE to silence warnings under some compilers */ +#if defined(__GUNC__) || defined(__clang__) || defined(USE_CC_ATTRIBUTE) + #define CC_ATTRIBUTE(_x) __attribute__ ((_x)) +#else + #define CC_ATTRIBUTE(_x) +#endif /* Note our global private identifiers end with '__' to mitigate risk of clash * with the unit tests implementation. */ @@ -462,7 +468,7 @@ static jmp_buf test_abort_jmp_buf__; #define TEST_COLOR_GREEN_INTENSIVE__ 4 #define TEST_COLOR_RED_INTENSIVE__ 5 -static int __attribute__((format (printf, 2, 3))) +static int CC_ATTRIBUTE(format (printf, 2, 3)) test_print_in_color__(int color, const char* fmt, ...) { va_list args; @@ -591,7 +597,7 @@ test_line_indent__(int level) printf("%.*s", n, spaces); } -int __attribute__((format (printf, 4, 5))) +int CC_ATTRIBUTE(format (printf, 4, 5)) test_check__(int cond, const char* file, int line, const char* fmt, ...) { const char *result_str; @@ -655,7 +661,7 @@ test_check__(int cond, const char* file, int line, const char* fmt, ...) return !test_cond_failed__; } -void __attribute__((format (printf, 1, 2))) +void CC_ATTRIBUTE(format (printf, 1, 2)) test_case__(const char* fmt, ...) { va_list args; @@ -684,7 +690,7 @@ test_case__(const char* fmt, ...) } } -void __attribute__((format (printf, 1, 2))) +void CC_ATTRIBUTE(format (printf, 1, 2)) test_message__(const char* fmt, ...) { char buffer[TEST_MSG_MAXSIZE]; @@ -882,7 +888,7 @@ test_lookup__(const char* pattern) /* Called if anything goes bad in Acutest, or if the unit test ends in other * way then by normal returning from its function (e.g. exception or some * abnormal child process termination). */ -static void __attribute__((format (printf, 1, 2))) +static void CC_ATTRIBUTE(format (printf, 1, 2)) test_error__(const char* fmt, ...) { va_list args;