From bd864ab42b763e557bcbe2bf3f1bc1fcd5e9950e Mon Sep 17 00:00:00 2001 From: Eugene Zhulenev Date: Mon, 28 Oct 2019 15:45:09 -0700 Subject: Prevent potential ODR in TensorExecutor --- unsupported/Eigen/CXX11/src/Tensor/TensorExecutor.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'unsupported/Eigen/CXX11/src/Tensor/TensorExecutor.h') diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorExecutor.h b/unsupported/Eigen/CXX11/src/Tensor/TensorExecutor.h index f736c238f..4f72156a4 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorExecutor.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorExecutor.h @@ -82,6 +82,13 @@ class TensorExecutor { public: typedef typename Expression::Index StorageIndex; + // Including `unsupported/Eigen/CXX11/Tensor` in different translation units + // with/without `EIGEN_USE_THREADS` is an ODR violation. If this template + // is instantiated with a thread pool device, it means that this header + // file was included without defining `EIGEN_USE_THREADS`. + static_assert(!std::is_same::value, + "You are missing `#define EIGEN_USE_THREADS`"); + EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void run(const Expression& expr, const Device& device = Device()) { -- cgit v1.2.3