atl_throw.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Copyright 2020 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef BASE_WIN_ATL_THROW_H_
  5. #define BASE_WIN_ATL_THROW_H_
  6. #ifdef __ATLDEF_H__
  7. #error atl_throw.h must be included before atldef.h.
  8. #endif
  9. #include "base/base_export.h"
  10. #include "base/win/windows_types.h"
  11. // Defining _ATL_NO_EXCEPTIONS causes ATL to raise a structured exception
  12. // instead of throwing a CAtlException. While crashpad will eventually handle
  13. // this, the HRESULT that caused the problem is lost. So, in addition, define
  14. // our own custom AtlThrow function (_ATL_CUSTOM_THROW).
  15. #ifndef _ATL_NO_EXCEPTIONS
  16. #define _ATL_NO_EXCEPTIONS
  17. #endif
  18. #define _ATL_CUSTOM_THROW
  19. #define AtlThrow ::base::win::AtlThrowImpl
  20. namespace base {
  21. namespace win {
  22. // Crash the process forthwith in case of ATL errors.
  23. [[noreturn]] BASE_EXPORT void __stdcall AtlThrowImpl(HRESULT hr);
  24. } // namespace win
  25. } // namespace base
  26. #include <atldef.h>
  27. // atldef.h mistakenly leaves out the declaration of this function when
  28. // _ATL_CUSTOM_THROW is defined.
  29. namespace ATL {
  30. ATL_NOINLINE __declspec(noreturn) inline void WINAPI AtlThrowLastWin32();
  31. }
  32. #endif // BASE_WIN_ATL_THROW_H_