diff --git a/include/dmlc/base.h b/include/dmlc/base.h index 3e76385715..29f4a1e1a4 100644 --- a/include/dmlc/base.h +++ b/include/dmlc/base.h @@ -92,6 +92,12 @@ #endif #endif +/*! \brief Whether to use modern thread local construct */ +#ifndef DMLC_MODERN_THREAD_LOCAL +#define DMLC_MODERN_THREAD_LOCAL 1 +#endif + + /*! \brief whether RTTI is enabled */ #ifndef DMLC_ENABLE_RTTI diff --git a/include/dmlc/thread_local.h b/include/dmlc/thread_local.h index fecaef8686..b10939c20e 100644 --- a/include/dmlc/thread_local.h +++ b/include/dmlc/thread_local.h @@ -36,7 +36,7 @@ class ThreadLocalStore { public: /*! \return get a thread local singleton */ static T* Get() { -#if DMLC_CXX11_THREAD_LOCAL +#if DMLC_CXX11_THREAD_LOCAL && DMLC_MODERN_THREAD_LOCAL == 1 static thread_local T inst; return &inst; #else