From f151a5d11db0330cbbc7fbde3b4b76c328357b25 Mon Sep 17 00:00:00 2001 From: bzt Date: Fri, 13 Dec 2019 09:04:40 +0100 Subject: [PATCH] MSVC2013 alternative to thread_local --- code/M3D/M3DWrapper.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/code/M3D/M3DWrapper.cpp b/code/M3D/M3DWrapper.cpp index 46f3278cb..c0de1cf31 100644 --- a/code/M3D/M3DWrapper.cpp +++ b/code/M3D/M3DWrapper.cpp @@ -48,10 +48,20 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -// workaround: the M3D SDK expects a C callback, but we want to use Assimp::IOSystem to implement that +#if (__cplusplus >= 201103L) || !defined(_MSC_VER) || (_MSC_VER >= 1900) // C++11 and MSVC 2015 onwards +# define threadlocal thread_local +#else +# if defined(_MSC_VER) && (_MSC_VER >= 1800) // there's an alternative for MSVC 2013 +# define threadlocal __declspec(thread) +# else +# define threadlocal +# endif +#endif extern "C" { -thread_local void *m3dimporter_pIOHandler; + +// workaround: the M3D SDK expects a C callback, but we want to use Assimp::IOSystem to implement that +threadlocal void *m3dimporter_pIOHandler; unsigned char *m3dimporter_readfile(char *fn, unsigned int *size) { ai_assert(nullptr != fn);