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.
This commit is contained in:
Ray molenkamp 2020-11-10 08:48:18 -07:00
parent bd6bfba64d
commit 626a79204e
1 changed files with 8 additions and 4 deletions

View File

@ -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