Add DOUBLE_CONVERSION_HAS_ATTRIBUTE to fix warnings on MSVC and enable for GCC. (#131)
diff --git a/double-conversion/utils.h b/double-conversion/utils.h
index 471c3da..438d055 100644
--- a/double-conversion/utils.h
+++ b/double-conversion/utils.h
@@ -56,15 +56,23 @@
#endif
#endif
+// Not all compilers support __has_attribute and combining a check for both
+// ifdef and __has_attribute on the same preprocessor line isn't portable.
+#ifdef __has_attribute
+# define DOUBLE_CONVERSION_HAS_ATTRIBUTE(x) __has_attribute(x)
+#else
+# define DOUBLE_CONVERSION_HAS_ATTRIBUTE(x) 0
+#endif
+
#ifndef DOUBLE_CONVERSION_UNUSED
-#ifdef __GNUC__
+#if DOUBLE_CONVERSION_HAS_ATTRIBUTE(unused)
#define DOUBLE_CONVERSION_UNUSED __attribute__((unused))
#else
#define DOUBLE_CONVERSION_UNUSED
#endif
#endif
-#if defined(__clang__) && __has_attribute(uninitialized)
+#if DOUBLE_CONVERSION_HAS_ATTRIBUTE(uninitialized)
#define DOUBLE_CONVERSION_STACK_UNINITIALIZED __attribute__((uninitialized))
#else
#define DOUBLE_CONVERSION_STACK_UNINITIALIZED