Browse Source

Disable unused function warning for GCC

GCC unused function attribute seems fundamentally broken.
Several attempts to tell the compiler "THIS FUNCTION MAY BE USED
OR UNUSED" for individual functions failed.
Either the compiler creates an "unused-function" warning if a
function is not marked with __attribute__((unused)).
On the other hand, if the function is marked with this attribute,
but is used, the compiler raises a completely idiotic
"used-but-marked-unused" warning - and
  #pragma GCC diagnostic ignored "-Wused-but-marked-unused"
raises error: unknown option after ‘#pragma GCC diagnostic’.
Disable this warning completely, until the GCC guys sober up
again.
bel2125 8 năm trước cách đây
mục cha
commit
1db02ca547
1 tập tin đã thay đổi với 16 bổ sung2 xóa
  1. 16 2
      src/civetweb.c

+ 16 - 2
src/civetweb.c

@@ -131,9 +131,23 @@ mg_static_assert(sizeof(void *) >= sizeof(int), "data type size check");
 
 #if defined(__GNUC__) || defined(__MINGW32__)
 
-#pragma GCC diagnostic ignored "-Wused-but-marked-unused"
+/* GCC unused function attribute seems fundamentally broken.
+ * Several attempts to tell the compiler "THIS FUNCTION MAY BE USED
+ * OR UNUSED" for individual functions failed.
+ * Either the compiler creates an "unused-function" warning if a
+ * function is not marked with __attribute__((unused)).
+ * On the other hand, if the function is marked with this attribute,
+ * but is used, the compiler raises a completely idiotic
+ * "used-but-marked-unused" warning - and
+ *   #pragma GCC diagnostic ignored "-Wused-but-marked-unused"
+ * raises error: unknown option after ‘#pragma GCC diagnostic’.
+ * Disable this warning completely, until the GCC guys sober up
+ * again.
+ */
+
+#pragma GCC diagnostic ignored "-Wunused-function"
 
-#define FUNCTION_MAY_BE_UNUSED __attribute__((unused))
+#define FUNCTION_MAY_BE_UNUSED /* __attribute__((unused)) */
 
 #else
 #define FUNCTION_MAY_BE_UNUSED