Index: CMakeLists.txt =================================================================== --- CMakeLists.txt +++ CMakeLists.txt @@ -135,6 +135,7 @@ # about #include_next which is used everywhere. option(LIBCXX_ENABLE_PEDANTIC "Compile with pedantic enabled." OFF) option(LIBCXX_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF) +option(LIBCXX_DISABLE_MACRO_CONFLICT_WARNINGS "Disable #warnings about conflicting macros." OFF) option(LIBCXX_GENERATE_COVERAGE "Enable generating code coverage." OFF) set(LIBCXX_COVERAGE_LIBRARY "" CACHE STRING @@ -323,6 +324,9 @@ if (LIBCXX_ENABLE_PEDANTIC) add_compile_flags_if_supported(-pedantic) endif() +if (LIBCXX_DISABLE_MACRO_CONFLICT_WARNINGS) + add_definitions(-D_LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS) +endif() # Exception flags ============================================================= if (LIBCXX_ENABLE_EXCEPTIONS) Index: include/__undef___deallocate =================================================================== --- include/__undef___deallocate +++ include/__undef___deallocate @@ -9,10 +9,12 @@ //===----------------------------------------------------------------------===// #ifdef __deallocate +#if !defined(_LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS) #if defined(_MSC_VER) && !defined(__clang__) _LIBCPP_WARNING("macro __deallocate is incompatible with C++. #undefining __deallocate") #else #warning: macro __deallocate is incompatible with C++. #undefining __deallocate #endif +#endif #undef __deallocate #endif Index: include/__undef_min_max =================================================================== --- include/__undef_min_max +++ include/__undef_min_max @@ -9,21 +9,25 @@ //===----------------------------------------------------------------------===// #ifdef min +#if !defined(_LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS) #if defined(_MSC_VER) && ! defined(__clang__) _LIBCPP_WARNING("macro min is incompatible with C++. Try #define NOMINMAX " "before any Windows header. #undefing min") #else #warning: macro min is incompatible with C++. #undefing min #endif +#endif #undef min #endif #ifdef max +#if !defined(_LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS) #if defined(_MSC_VER) && ! defined(__clang__) _LIBCPP_WARNING("macro max is incompatible with C++. Try #define NOMINMAX " "before any Windows header. #undefing max") #else #warning: macro max is incompatible with C++. #undefing max #endif +#endif #undef max #endif