Explicitly handle gcc in FOLLY_MAYBE_UNUSED
authorYedidya Feldblum <yfeldblum@fb.com>
Wed, 9 Aug 2017 21:55:17 +0000 (14:55 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Wed, 9 Aug 2017 21:57:42 +0000 (14:57 -0700)
Summary:
[Folly] Explicitly handle gcc in `FOLLY_MAYBE_UNUSED`.

Fixes build break from {D5562220}.

Reviewed By: Orvid

Differential Revision: D5594288

fbshipit-source-id: 5aa2dcb6133d53a0eb20d34b67c8e4407dd2b7ca

folly/CppAttributes.h

index f435212d157986c28aa34c27199400014675b01b..7a13f61517cd1220666f6c5b4c5e551e718e03bd 100644 (file)
 
 #pragma once
 
 
 #pragma once
 
+#ifndef __has_attribute
+#define FOLLY_HAS_ATTRIBUTE(x) 0
+#else
+#define FOLLY_HAS_ATTRIBUTE(x) __has_attribute(x)
+#endif
+
 #ifndef __has_cpp_attribute
 #define FOLLY_HAS_CPP_ATTRIBUTE(x) 0
 #else
 #ifndef __has_cpp_attribute
 #define FOLLY_HAS_CPP_ATTRIBUTE(x) 0
 #else
@@ -65,7 +71,9 @@
  *    #endif
  *  }
  */
  *    #endif
  *  }
  */
-#if FOLLY_HAS_CPP_ATTRIBUTE(__unused__)
+#if FOLLY_HAS_CPP_ATTRIBUTE(maybe_unused)
+#define FOLLY_MAYBE_UNUSED [[maybe_unused]]
+#elif FOLLY_HAS_ATTRIBUTE(__unused__) || __GNUC__
 #define FOLLY_MAYBE_UNUSED __attribute__((__unused__))
 #else
 #define FOLLY_MAYBE_UNUSED
 #define FOLLY_MAYBE_UNUSED __attribute__((__unused__))
 #else
 #define FOLLY_MAYBE_UNUSED