From 626a79204ee2a9023cca1f7b9dfd88aa8d25cfc6 Mon Sep 17 00:00:00 2001 From: Ray Molenkamp Date: Tue, 10 Nov 2020 08:48:18 -0700 Subject: MSVC: Fix build warning If a define of NOMINMAX was made before BLI_task.hh was included, the compiler would emit a warning C4005: 'NOMINMAX': macro redefinition warning, to work around this only define it if it is not already defined, and only undefine it if we were the ones that made the define earlier. --- source/blender/blenlib/BLI_task.hh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'source/blender/blenlib') diff --git a/source/blender/blenlib/BLI_task.hh b/source/blender/blenlib/BLI_task.hh index 8a0d77745c8..0da03d84793 100644 --- a/source/blender/blenlib/BLI_task.hh +++ b/source/blender/blenlib/BLI_task.hh @@ -24,16 +24,20 @@ /* Quiet top level deprecation message, unrelated to API usage here. */ # define TBB_SUPPRESS_DEPRECATED_MESSAGES 1 -# ifdef WIN32 +# if defined(WIN32) && !defined(NOMINMAX) /* TBB includes Windows.h which will define min/max macros causing issues * when we try to use std::min and std::max later on. */ # define NOMINMAX +# define TBB_MIN_MAX_CLEANUP # endif # include # ifdef WIN32 -/* We cannot keep this defined, since other parts of the code deal with this on their own leading - * to multiple define warnings unless we un-define this. */ -# undef NOMINMAX +/* We cannot keep this defined, since other parts of the code deal with this on their own, leading + * to multiple define warnings unless we un-define this, however we can only undefine this if we + * were the ones that made the definition earlier. */ +# ifdef TBB_MIN_MAX_CLEANUP +# undef NOMINMAX +# endif # endif #endif -- cgit v1.2.3