]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
acutest needs to work with compilers other than gcc and clang
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 30 Jan 2020 20:14:46 +0000 (15:14 -0500)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 30 Jan 2020 20:14:57 +0000 (15:14 -0500)
src/lib/util/acutest.h

index 1c12a199eb2f41c32b2f437d353f6abdd56a70c0..c60416864faa0279b1cce43d9aa39ef7299052e5 100644 (file)
     #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;