1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2  * vim: sw=2 ts=8 et :
3  */
4 /* This Source Code Form is subject to the terms of the Mozilla Public
5  * License, v. 2.0. If a copy of the MPL was not distributed with this
6  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 
8 #ifndef mozilla_${HEADER}_h
9 #define mozilla_${HEADER}_h
10 
11 #if _HAS_EXCEPTIONS
12 #  error "STL code can only be used with -fno-exceptions"
13 #endif
14 
15 #if defined(__clang__)
16 // Silence "warning: #include_next is a language extension [-Wgnu-include-next]"
17 #pragma clang system_header
18 #endif
19 
20 // Include mozalloc after the STL header and all other headers it includes
21 // have been preprocessed.
22 #if !defined(MOZ_INCLUDE_MOZALLOC_H)
23 #  define MOZ_INCLUDE_MOZALLOC_H
24 #  define MOZ_INCLUDE_MOZALLOC_H_FROM_${HEADER}
25 #endif
26 
27 #ifdef _DEBUG
28 // From
29 //   http://msdn.microsoft.com/en-us/library/aa985982%28VS.80%29.aspx
30 // and
31 //   http://msdn.microsoft.com/en-us/library/aa985965%28VS.80%29.aspx
32 // there appear to be two types of STL container checking.  The
33 // former is enabled by -D_DEBUG (which is implied by -MDd or -MTd), and
34 // looks to be full generation/mutation checked iterators as done by
35 // _GLIBCXX_DEBUG.  The latter appears to just be bounds checking, and
36 // is enabled by the following macros.  It appears that the _DEBUG
37 // iterators subsume _SECURE_SCL, and the following settings are
38 // default anyway, so we'll just leave this commented out.
39 //#  define _SECURE_SCL 1
40 //#  define _SECURE_SCL_THROWS 0
41 #else
42 // Note: _SECURE_SCL iterators are on by default in opt builds.  We
43 // could leave them on, but since gcc doesn't, we might as well
44 // preserve that behavior for perf reasons.  nsTArray is in the same
45 // camp as gcc.  Can revisit later.
46 //
47 // FIXME/bug 551254: because we're not wrapping all the STL headers we
48 // use, undefining this here can cause some headers to be built with
49 // iterator checking and others not.  Turning this off until we have a
50 // better plan.
51 //#  undef _SECURE_SCL
52 #endif
53 
54 #include_next <${HEADER}>
55 
56 #ifdef MOZ_INCLUDE_MOZALLOC_H_FROM_${HEADER}
57 // See if we're in code that can use mozalloc.
58 #  if !defined(NS_NO_XPCOM) && !defined(MOZ_NO_MOZALLOC)
59 #    include "mozilla/mozalloc.h"
60 #  else
61 #    error "STL code can only be used with infallible ::operator new()"
62 #  endif
63 #endif
64 
65 #endif  // if mozilla_${HEADER}_h
66