diff --git a/blockingconcurrentqueue.h b/blockingconcurrentqueue.h index 205a4db7..4c9174a8 100644 --- a/blockingconcurrentqueue.h +++ b/blockingconcurrentqueue.h @@ -7,6 +7,13 @@ #pragma once +// Work around potential conflict with system headers (e.g., ) that define BLOCK_SIZE as a macro +#ifdef BLOCK_SIZE +#pragma push_macro("BLOCK_SIZE") +#undef BLOCK_SIZE +#define CONCURRENTQUEUE_BLOCK_SIZE_WAS_DEFINED +#endif + #include "concurrentqueue.h" #include "lightweightsemaphore.h" @@ -580,3 +587,9 @@ inline void swap(BlockingConcurrentQueue& a, BlockingConcurrentQueue< } } // end namespace moodycamel + +// Restore BLOCK_SIZE macro if it was defined before +#ifdef CONCURRENTQUEUE_BLOCK_SIZE_WAS_DEFINED +#pragma pop_macro("BLOCK_SIZE") +#undef CONCURRENTQUEUE_BLOCK_SIZE_WAS_DEFINED +#endif diff --git a/concurrentqueue.h b/concurrentqueue.h index 9d00070f..d860a4f4 100644 --- a/concurrentqueue.h +++ b/concurrentqueue.h @@ -50,6 +50,13 @@ #pragma warning(disable: 4127) // conditional expression is constant #endif +// Work around potential conflict with system headers (e.g., ) that define BLOCK_SIZE as a macro +#ifdef BLOCK_SIZE +#pragma push_macro("BLOCK_SIZE") +#undef BLOCK_SIZE +#define CONCURRENTQUEUE_BLOCK_SIZE_WAS_DEFINED +#endif + #if defined(__APPLE__) #include "TargetConditionals.h" #endif @@ -3738,6 +3745,12 @@ inline void swap(typename ConcurrentQueue::ImplicitProducerKVP& a, ty } +// Restore BLOCK_SIZE macro if it was defined before +#ifdef CONCURRENTQUEUE_BLOCK_SIZE_WAS_DEFINED +#pragma pop_macro("BLOCK_SIZE") +#undef CONCURRENTQUEUE_BLOCK_SIZE_WAS_DEFINED +#endif + #if defined(_MSC_VER) && (!defined(_HAS_CXX17) || !_HAS_CXX17) #pragma warning(pop) #endif