lwt_unattended.hpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #ifndef BOOST_CORE_DETAIL_LWT_UNATTENDED_HPP_INCLUDED
  2. #define BOOST_CORE_DETAIL_LWT_UNATTENDED_HPP_INCLUDED
  3. // Copyright 2014, 2022 Peter Dimov
  4. // Distributed under the Boost Software License, Version 1.0.
  5. // https://www.boost.org/LICENSE_1_0.txt
  6. #include <cstdlib>
  7. #if defined(_MSC_VER) && defined(_CPPLIB_VER) && defined(_DEBUG)
  8. # include <crtdbg.h>
  9. #endif
  10. namespace boost
  11. {
  12. namespace core
  13. {
  14. namespace detail
  15. {
  16. // Setup unattended mode by disabling interactive popups on
  17. // assertion failures
  18. inline void lwt_unattended()
  19. {
  20. #if defined(_MSC_VER) && (_MSC_VER > 1310)
  21. // disable message boxes on assert(), abort()
  22. ::_set_abort_behavior( 0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT );
  23. # pragma warning(push)
  24. # pragma warning(disable: 4996)
  25. # if defined(__clang__)
  26. # pragma clang diagnostic push
  27. # pragma clang diagnostic ignored "-Wdeprecated-declarations"
  28. # endif
  29. #if !defined(WINAPI_FAMILY) || WINAPI_FAMILY == 100 /*WINAPI_FAMILY_DESKTOP_APP*/
  30. // disable message box on crash
  31. ::_seterrormode( /*SEM_NOGPFAULTERRORBOX*/ 0x0002 );
  32. #endif
  33. # if defined(__clang__)
  34. # pragma clang diagnostic pop
  35. # endif
  36. # pragma warning(pop)
  37. #endif
  38. #if defined(_MSC_VER) && defined(_CPPLIB_VER) && defined(_DEBUG)
  39. // disable message boxes on iterator debugging violations
  40. _CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE );
  41. _CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDERR );
  42. #endif
  43. }
  44. } // namespace detail
  45. } // namespace core
  46. } // namespace boost
  47. #endif // #ifndef BOOST_CORE_DETAIL_LWT_UNATTENDED_HPP_INCLUDED