Bug 1848746 - Avoid problems when <exception> is included before <new>. r=firefox-build-system-reviewers,ahochheiden

Differential Revision: https://phabricator.services.mozilla.com/D186201
This commit is contained in:
Mike Hommey
2023-08-15 20:11:14 +00:00
parent f4b697bbd8
commit cdd712f153

View File

@@ -56,6 +56,13 @@
#ifdef MOZ_INCLUDE_MOZALLOC_H_FROM_${HEADER} #ifdef MOZ_INCLUDE_MOZALLOC_H_FROM_${HEADER}
// See if we're in code that can use mozalloc. // See if we're in code that can use mozalloc.
# if !defined(NS_NO_XPCOM) && !defined(MOZ_NO_MOZALLOC) # if !defined(NS_NO_XPCOM) && !defined(MOZ_NO_MOZALLOC)
// In recent versions of MSVC, <new>, which mozalloc.h includes, uses
// <type_traits> without including it. Before MSVC 17.7, this worked
// fine because <new> included <exception>, which includes <type_traits>.
// That is still the case, but it now also includes <cstdlib> before
// <type_traits>, so when something includes <exception> before <new>,
// we get here before <type_traits> is included, which ends up not working.
# include <type_traits>
# include "mozilla/mozalloc.h" # include "mozilla/mozalloc.h"
# else # else
# error "STL code can only be used with infallible ::operator new()" # error "STL code can only be used with infallible ::operator new()"