summaryrefslogtreecommitdiff
path: root/src/cc-compat.h
diff options
context:
space:
mode:
authorlhchavez <lhchavez@lhchavez.com>2021-02-23 19:33:34 -0800
committerlhchavez <lhchavez@lhchavez.com>2021-08-08 19:08:59 -0700
commit231ca4fad36ce7b3dd5d79b599be46ab6001fc18 (patch)
tree6616d81c71b873f122134f046073defcc4f659c2 /src/cc-compat.h
parent9eb17d460cd681bbc14d56ed8fdf440bc69b5456 (diff)
downloadlibgit2-231ca4fad36ce7b3dd5d79b599be46ab6001fc18.tar.gz
Proof-of-concept for a more aggressive GIT_UNUSED()
This adds a `-Wunused-result`-proof `GIT_UNUSED()`, just to demonstrate that it works. With this, sortedcache.h is now completely `GIT_WARN_UNUSED_RESULT`-annotated!
Diffstat (limited to 'src/cc-compat.h')
-rw-r--r--src/cc-compat.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/cc-compat.h b/src/cc-compat.h
index de1469da8..21f321124 100644
--- a/src/cc-compat.h
+++ b/src/cc-compat.h
@@ -43,7 +43,15 @@
# define GIT_ALIGN(x,size) x
#endif
-#define GIT_UNUSED(x) ((void)(x))
+#if defined(__GNUC__)
+# define GIT_UNUSED(x) \
+ do { \
+ typeof(x) _unused __attribute__((unused)); \
+ _unused = (x); \
+ } while (0)
+#else
+# define GIT_UNUSED(x) ((void)(x))
+#endif
/* Define the printf format specifier to use for size_t output */
#if defined(_MSC_VER) || defined(__MINGW32__)