1

尝试在 Cygwin 环境中编译以下代码:

#include <boost/process.hpp>

int main() { }

并得到以下错误:

In file included from /usr/include/boost/process/detail/child_decl.hpp:31:0,
                 from /usr/include/boost/process/child.hpp:21,
                 from /usr/include/boost/process/async_system.hpp:22,
                 from /usr/include/boost/process.hpp:24,
                 from bp.cpp:2:
/usr/include/boost/process/detail/posix/is_running.hpp:18:1: error: non-constant condition for static assertion
 static_assert(!WIFEXITED(still_active), "Internal Error");
 ^~~~~~~~~~~~~
In file included from /usr/include/cygwin/stdlib.h:13:0,
                 from /usr/include/stdlib.h:26,
                 from /usr/lib/gcc/x86_64-pc-cygwin/7.3.0/include/c++/cstdlib:75,
                 from /usr/lib/gcc/x86_64-pc-cygwin/7.3.0/include/c++/ext/string_conversions.h:41,
                 from /usr/lib/gcc/x86_64-pc-cygwin/7.3.0/include/c++/bits/basic_string.h:6349,
                 from /usr/lib/gcc/x86_64-pc-cygwin/7.3.0/include/c++/string:52,
                 from /usr/lib/gcc/x86_64-pc-cygwin/7.3.0/include/c++/stdexcept:39,
                 from /usr/lib/gcc/x86_64-pc-cygwin/7.3.0/include/c++/system_error:41,
                 from /usr/include/boost/process/detail/config.hpp:21,
                 from /usr/include/boost/process/detail/basic_cmd.hpp:10,
                 from /usr/include/boost/process/args.hpp:33,
                 from /usr/include/boost/process.hpp:22,
                 from bp.cpp:2:
/usr/include/boost/process/detail/posix/is_running.hpp:18:16: error: call to non-constexpr function 'int __wait_status_to_int(int)'
 static_assert(!WIFEXITED(still_active), "Internal Error");
                ^

你能建议如何解决它吗?

我正在使用 Boost 1.66。

4

1 回答 1

1

WIFEXITED 宏扩展为对 __wait_status_to_int 的函数调用。这个不能在编译时调用。

这是一个错误升压过程在赛格温。

根据

https://github.com/openunix/cygwin/blob/master/winsup/cygwin/include/sys/wait.h

__wait_status_to_int 是一个宏,对于 C++,它们删除了宏,而是提供了两个重载函数。

于 2018-06-08T14:13:53.907 回答