config.hpp
Go to the documentation of this file.
1 // Copyright (c) 2006, 2007 Julio M. Merino Vidal
2 // Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
3 // Copyright (c) 2009 Boris Schaeling
4 // Copyright (c) 2010 Felipe Tanus, Boris Schaeling
5 // Copyright (c) 2011, 2012 Jeff Flinn, Boris Schaeling
6 //
7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 
10 /**
11  * \file boost/process/config.hpp
12  *
13  * Defines various macros.
14  */
15 
16 #pragma once
17 
18 #include <boost/config.hpp>
19 #include <boost/system/config.hpp>
20 #include <boost/system/error_code.hpp>
21 #include <boost/system/system_error.hpp>
22 
23 #if defined(BOOST_POSIX_API)
24 # include <errno.h>
25 # define BOOST_PROCESS_LAST_ERROR errno
26 # define BOOST_PROCESS_PLATFORM posix
27 #elif defined(BOOST_WINDOWS_API)
28 # include <Windows.h>
29 # define BOOST_PROCESS_LAST_ERROR GetLastError()
30 # define BOOST_PROCESS_PLATFORM windows
31 #endif
32 
33 /** \cond */
34 #define BOOST_PROCESS_PLATFORM_PROMOTE_PATH(COMPONENT) \
35  <boost/process/BOOST_PROCESS_PLATFORM/COMPONENT.hpp>
36 #define BOOST_PROCESS_PLATFORM_PROMOTE_NAMESPACE(COMPONENT) \
37  namespace boost::process { using BOOST_PROCESS_PLATFORM::COMPONENT; }
38 #define BOOST_PROCESS_PLATFORM_PROMOTE_INITIALIZERS_NAMESPACE \
39  namespace boost::process::initializers { \
40  using namespace boost::process::BOOST_PROCESS_PLATFORM::initializers; }
41 /** \endcond */
42 
43 #if defined(BOOST_PROCESS_DOXYGEN)
44 /**
45  * \def BOOST_POSIX_API
46  *
47  * This macro is defined on POSIX.
48  */
49 #define BOOST_POSIX_API
50 /**
51  * \def BOOST_WINDOWS_API
52  *
53  * This macro is defined on Windows.
54  */
55 #define BOOST_WINDOWS_API
56 #endif
57 
58 /**
59  * \def BOOST_PROCESS_THROW(EX)
60  *
61  * Defines how exceptions are thrown. Set this macro for example
62  * to \c BOOST_THROW_EXCEPTION if you like to use Boost.Exception.
63  */
64 #define BOOST_PROCESS_THROW(EX) throw EX
65 
66 /** \cond */
67 #define BOOST_PROCESS_SOURCE_LOCATION \
68  "in file '" __FILE__ "', line " BOOST_STRINGIZE(__LINE__) ": "
69 
70 #define BOOST_PROCESS_THROW_LAST_SYSTEM_ERROR(what) \
71  BOOST_PROCESS_THROW(boost::system::system_error( \
72  boost::system::error_code(BOOST_PROCESS_LAST_ERROR, \
73  boost::system::system_category()), \
74  BOOST_PROCESS_SOURCE_LOCATION what))
75 
76 #define BOOST_PROCESS_RETURN_LAST_SYSTEM_ERROR(ec) \
77  ec = boost::system::error_code(BOOST_PROCESS_LAST_ERROR, \
78  boost::system::system_category())
79 /** \endcond */
80