Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Molenkamp <github@lazydodo.com>2020-11-10 18:48:18 +0300
committerRay Molenkamp <github@lazydodo.com>2020-11-10 18:48:18 +0300
commit626a79204ee2a9023cca1f7b9dfd88aa8d25cfc6 (patch)
tree2cba153272c61a9716adaeb7fbea967bd87e3c58 /source/blender/blenlib
parentbd6bfba64dad2e14cab2c8372ba0f3ad39b93cdc (diff)
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.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/BLI_task.hh12
1 files changed, 8 insertions, 4 deletions
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 <tbb/tbb.h>
# 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