1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/config/msvc-stl-wrapper.template.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,77 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- 1.5 + * vim: sw=2 ts=8 et : 1.6 + */ 1.7 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.8 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.9 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.10 + 1.11 +#ifndef mozilla_${HEADER}_h 1.12 +#define mozilla_${HEADER}_h 1.13 + 1.14 +#if _HAS_EXCEPTIONS 1.15 +# error "STL code can only be used with -fno-exceptions" 1.16 +#endif 1.17 + 1.18 +// Suppress windef.h min and max macros - they make std::min/max not compile. 1.19 +#define NOMINMAX 1 1.20 + 1.21 +// Code built with !_HAS_EXCEPTIONS calls std::_Throw(), but the win2k 1.22 +// CRT doesn't export std::_Throw(). So we define it. 1.23 +#ifndef mozilla_Throw_h 1.24 +# include "mozilla/throw_msvc.h" 1.25 +#endif 1.26 + 1.27 +// Code might include <new> before other wrapped headers, but <new> 1.28 +// includes <exception> and so we want to wrap it. But mozalloc.h 1.29 +// wants <new> also, so we break the cycle by always explicitly 1.30 +// including <new> here. 1.31 +#include <${NEW_HEADER_PATH}> 1.32 + 1.33 +// See if we're in code that can use mozalloc. NB: this duplicates 1.34 +// code in nscore.h because nscore.h pulls in prtypes.h, and chromium 1.35 +// can't build with that being included before base/basictypes.h. 1.36 +#if !defined(XPCOM_GLUE) && !defined(NS_NO_XPCOM) && !defined(MOZ_NO_MOZALLOC) 1.37 +# include "mozilla/mozalloc.h" 1.38 +#else 1.39 +# error "STL code can only be used with infallible ::operator new()" 1.40 +#endif 1.41 + 1.42 +#ifdef DEBUG 1.43 +// From 1.44 +// http://msdn.microsoft.com/en-us/library/aa985982%28VS.80%29.aspx 1.45 +// and 1.46 +// http://msdn.microsoft.com/en-us/library/aa985965%28VS.80%29.aspx 1.47 +// there appear to be two types of STL container checking. The 1.48 +// former is enabled by -D_DEBUG (which is implied by -DDEBUG), and 1.49 +// looks to be full generation/mutation checked iterators as done by 1.50 +// _GLIBCXX_DEBUG. The latter appears to just be bounds checking, and 1.51 +// is enabled by the following macros. It appears that the _DEBUG 1.52 +// iterators subsume _SECURE_SCL, and the following settings are 1.53 +// default anyway, so we'll just leave this commented out. 1.54 +//# define _SECURE_SCL 1 1.55 +//# define _SECURE_SCL_THROWS 0 1.56 +#else 1.57 +// Note: _SECURE_SCL iterators are on by default in opt builds. We 1.58 +// could leave them on, but since gcc doesn't, we might as well 1.59 +// preserve that behavior for perf reasons. nsTArray is in the same 1.60 +// camp as gcc. Can revisit later. 1.61 +// 1.62 +// FIXME/bug 551254: because we're not wrapping all the STL headers we 1.63 +// use, undefining this here can cause some headers to be built with 1.64 +// iterator checking and others not. Turning this off until we have a 1.65 +// better plan. 1.66 +//# undef _SECURE_SCL 1.67 +#endif 1.68 + 1.69 +// C4275: When _HAS_EXCEPTIONS is set to 0, system STL header 1.70 +// will generate the warning which we can't modify. 1.71 +// C4530: We know that code won't be able to catch exceptions, 1.72 +// but that's OK because we're not throwing them. 1.73 +#pragma warning( push ) 1.74 +#pragma warning( disable : 4275 4530 ) 1.75 + 1.76 +#include <${HEADER_PATH}> 1.77 + 1.78 +#pragma warning( pop ) 1.79 + 1.80 +#endif // if mozilla_${HEADER}_h