Fix unused finalizer function warning
authorRobbie Harwood <rharwood@redhat.com>
Thu, 6 Apr 2017 18:43:13 +0000 (14:43 -0400)
committerGreg Hudson <ghudson@mit.edu>
Fri, 14 Apr 2017 16:02:58 +0000 (12:02 -0400)
When we are building a static object containing a finalizer function
(e.g. for the profile library tests), mark the finalizer as unused to
avoid warnings in gcc and clang.

[ghudson@mit.edu: commented UNUSED definition and moved it so we can
use it elsewhere later; rewrote commit message]

src/include/k5-platform.h

index 994f46323cb0b29f6be5ea5de950395f10c287f2..62d1e2a779cbd45dfdfa2ac73e4ef398904b8069 100644 (file)
 #define CAN_COPY_VA_LIST
 #endif
 
+/* This attribute prevents unused function warnings in gcc and clang. */
+#ifdef __GNUC__
+#define UNUSED __attribute__((__unused__))
+#else
+#define UNUSED
+#endif
+
 #if defined(macintosh) || (defined(__MACH__) && defined(__APPLE__))
 #include <TargetConditionals.h>
 #endif
@@ -357,14 +364,11 @@ typedef struct { int error; unsigned char did_run; } k5_init_t;
 #if !defined(SHARED) && !defined(_WIN32)
 
 /*
- * In this case, we just don't care about finalization.
- *
- * The code will still define the function, but we won't do anything
- * with it.  Annoying: This may generate unused-function warnings.
+ * In this case, we just don't care about finalization.  The code will still
+ * define the function, but we won't do anything with it.
  */
-
 # define MAKE_FINI_FUNCTION(NAME)               \
-        static void NAME(void)
+        static void NAME(void) UNUSED
 
 #elif defined(USE_LINKER_FINI_OPTION) || defined(_WIN32)
 /* If we're told the linker option will be used, it doesn't really