Search code examples
c++boostboost-process

boost::process cannot compile because of boost::throw_exception


When trying to include the boost::process library i get 2 errors relating to boost::process pipe.hpp file with the way it is handling exceptions.

'<function-style-cast>': cannot convert from 'initializer list' to 'boost::system::system_error' | pipe.hpp | line 129
'boost::throw_exception': no matching overloaded function found | pipe.hpp | line 129

Here is the offending line in boost::process pipe.hpp:

boost::throw_exception(boost::system::system_error(::GetLastError(), boost::system::system_category, "boost::process::detail::pipe::pipe: CreatePipe failed")); 

I assume this has something to do with how boost may have changed how it handles exceptions and boost::process not updating to support that, however i'm not familiar with how boost has changed. The whole pipe.hpp file throws exceptions like this but they dont show up in the errors as they are behind define guards that have not been defined.


Solution

  • Use boost::system::system_category() instead of boost::system::system_category. Note that the latter may have worked in older boost versions. See here.