Don't declare the extern FingerprintTable specializations under MSVC
authorChristopher Dykes <cdykes@fb.com>
Tue, 1 Nov 2016 23:50:28 +0000 (16:50 -0700)
committerFacebook Github Bot <facebook-github-bot-bot@fb.com>
Tue, 1 Nov 2016 23:53:30 +0000 (16:53 -0700)
Summary:
MSVC doesn't allow uninitialized non-`extern` `const` declarations, but we can't mark them `extern` because they are part of a template specialization. We also can't initialize them, because they'd conflict with the definition specializations in the generated tables.
As the forward-declarations aren't required for it to work under MSVC, as the specializations are found appropriately, just don't declare the specializations under MSVC.

Reviewed By: yfeldblum

Differential Revision: D4098282

fbshipit-source-id: 84b73d63bbe6cf9c54b7fe7a3bfc2488699df7c2

folly/Fingerprint.h

index a4400d5ddcb5eb54ce13724e9a77cd3c9db1c30f..1294a0d285107ef51ff5887b86975493a5d555ca 100644 (file)
@@ -63,6 +63,11 @@ const uint64_t FingerprintTable<BITS>::poly[1 + (BITS - 1) / 64] = {};
 template <int BITS>
 const uint64_t FingerprintTable<BITS>::table[8][256][1 + (BITS - 1) / 64] = {};
 
+#ifndef _MSC_VER
+// MSVC 2015 can't handle these extern specialization declarations,
+// but they aren't needed for things to work right, so we just don't
+// declare them in the header for MSVC.
+
 #define FOLLY_DECLARE_FINGERPRINT_TABLES(BITS)                      \
   template <>                                                       \
   const uint64_t FingerprintTable<BITS>::poly[1 + (BITS - 1) / 64]; \
@@ -74,6 +79,7 @@ FOLLY_DECLARE_FINGERPRINT_TABLES(96);
 FOLLY_DECLARE_FINGERPRINT_TABLES(128);
 
 #undef FOLLY_DECLARE_FINGERPRINT_TABLES
+#endif
 
 } // namespace detail