last_error.ipp 860 B

12345678910111213141516171819202122232425262728293031323334
  1. // Copyright (c) 2022 Klemens D. Morgenstern
  2. //
  3. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. #ifndef BOOST_PROCESS_V2_DETAIL_IMPL_LAST_ERROR_IPP
  6. #define BOOST_PROCESS_V2_DETAIL_IMPL_LAST_ERROR_IPP
  7. #include <boost/process/v2/detail/config.hpp>
  8. #include <boost/process/v2/detail/last_error.hpp>
  9. #if defined(BOOST_PROCESS_V2_WINDOWS)
  10. #include <windows.h>
  11. #else
  12. #include <cerrno>
  13. #endif
  14. BOOST_PROCESS_V2_BEGIN_NAMESPACE
  15. namespace detail
  16. {
  17. error_code get_last_error()
  18. {
  19. #if defined(BOOST_PROCESS_V2_WINDOWS)
  20. return error_code(::GetLastError(), system_category());
  21. #else
  22. return error_code(errno, system_category());
  23. #endif
  24. }
  25. }
  26. BOOST_PROCESS_V2_END_NAMESPACE
  27. #endif //BOOST_PROCESS_V2_DETAIL_IMPL_LAST_ERROR_IPP