msvc-stl-wrapper.template.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. #ifndef mozilla_${HEADER}_h
  8. #define mozilla_${HEADER}_h
  9. #if _HAS_EXCEPTIONS
  10. # error "STL code can only be used with -fno-exceptions"
  11. #endif
  12. // Include mozalloc after the STL header and all other headers it includes
  13. // have been preprocessed.
  14. #if !defined(MOZ_INCLUDE_MOZALLOC_H)
  15. # define MOZ_INCLUDE_MOZALLOC_H
  16. # define MOZ_INCLUDE_MOZALLOC_H_FROM_${HEADER}
  17. #endif
  18. // Code built with !_HAS_EXCEPTIONS calls std::_Throw(), but the win2k
  19. // CRT doesn't export std::_Throw(). So we define it.
  20. #ifndef mozilla_Throw_h
  21. # include "mozilla/throw_msvc.h"
  22. #endif
  23. #ifdef _DEBUG
  24. // From
  25. // http://msdn.microsoft.com/en-us/library/aa985982%28VS.80%29.aspx
  26. // and
  27. // http://msdn.microsoft.com/en-us/library/aa985965%28VS.80%29.aspx
  28. // there appear to be two types of STL container checking. The
  29. // former is enabled by -D_DEBUG (which is implied by -MDd or -MTd), and
  30. // looks to be full generation/mutation checked iterators as done by
  31. // _GLIBCXX_DEBUG. The latter appears to just be bounds checking, and
  32. // is enabled by the following macros. It appears that the _DEBUG
  33. // iterators subsume _SECURE_SCL, and the following settings are
  34. // default anyway, so we'll just leave this commented out.
  35. //# define _SECURE_SCL 1
  36. //# define _SECURE_SCL_THROWS 0
  37. #else
  38. // Note: _SECURE_SCL iterators are on by default in opt builds. We
  39. // could leave them on, but since gcc doesn't, we might as well
  40. // preserve that behavior for perf reasons. nsTArray is in the same
  41. // camp as gcc. Can revisit later.
  42. //
  43. // FIXME/bug 551254: because we're not wrapping all the STL headers we
  44. // use, undefining this here can cause some headers to be built with
  45. // iterator checking and others not. Turning this off until we have a
  46. // better plan.
  47. //# undef _SECURE_SCL
  48. #endif
  49. // C4275: When _HAS_EXCEPTIONS is set to 0, system STL header
  50. // will generate the warning which we can't modify.
  51. // C4530: We know that code won't be able to catch exceptions,
  52. // but that's OK because we're not throwing them.
  53. #pragma warning( push )
  54. #pragma warning( disable : 4275 4530 )
  55. #ifdef __clang__
  56. #include_next <${HEADER}>
  57. #else
  58. #include <${HEADER_PATH}>
  59. #endif
  60. #pragma warning( pop )
  61. #ifdef MOZ_INCLUDE_MOZALLOC_H_FROM_${HEADER}
  62. // See if we're in code that can use mozalloc. NB: this duplicates
  63. // code in nscore.h because nscore.h pulls in prtypes.h, and chromium
  64. // can't build with that being included before base/basictypes.h.
  65. # if !defined(XPCOM_GLUE) && !defined(NS_NO_XPCOM) && !defined(MOZ_NO_MOZALLOC)
  66. # include "mozilla/mozalloc.h"
  67. # else
  68. # error "STL code can only be used with infallible ::operator new()"
  69. # endif
  70. #endif
  71. #endif // if mozilla_${HEADER}_h