Commit 0caa2c14 authored by Christopher Dykes's avatar Christopher Dykes Committed by Facebook Github Bot

Workaround a bug in template instation in MSVC 2017.3 with /permissive-

Summary:
As described in the comment in `folly/stats/Histogram.h`, MSVC 2017.3 has issues with `/permissive-`.
The bug has been fixed upstream, it's just waiting for release.

These explicit template instantiations are never forward-declared anywhere, so, as long as `Histogram-defs.h` has been included, it's perfectly safe to just not do them.

https://developercommunity.visualstudio.com/content/problem/81223/incorrect-error-c5037-with-permissive.html

Reviewed By: yfeldblum

Differential Revision: D5828891

fbshipit-source-id: 4db8407c9d35aa5bb3f7b81aa24f611b5787fb6e
parent fb0a1228
......@@ -24,6 +24,7 @@
#include <folly/stats/Histogram.h>
#include <folly/stats/Histogram-defs.h>
#if !FOLLY_MSVC_USE_WORKAROUND_FOR_C5037
namespace folly {
template class Histogram<int64_t>;
......@@ -53,3 +54,4 @@ detail::HistogramBuckets<int64_t, Histogram<int64_t>::Bucket>::
Histogram<int64_t>::CountFromBucket countFromBucket) const;
} // namespace folly
#endif
......@@ -479,3 +479,18 @@ class Histogram {
};
} // namespace folly
// MSVC 2017 Update 3 has an issue with explicitly instantiating templated
// functions with default arguments inside templated classes when compiled
// with /permissive- (the default for the CMake build), so we directly include
// the -defs as if it were -inl, and don't provide the explicit instantiations.
// https://developercommunity.visualstudio.com/content/problem/81223/incorrect-error-c5037-with-permissive.html
#if defined(_MSC_VER) && _MSC_FULL_VER >= 191125506 && _MSC_FULL_VER < 191125542
#define FOLLY_MSVC_USE_WORKAROUND_FOR_C5037 1
#else
#define FOLLY_MSVC_USE_WORKAROUND_FOR_C5037 0
#endif
#if FOLLY_MSVC_USE_WORKAROUND_FOR_C5037
#include <folly/stats/Histogram-defs.h>
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment