cygwin Windows 10错误“ sigfillset在范围”中没有声明
Cygwin + windows 10 error "sigfillset was not declared in the scope"
我正在尝试使用Cygwin在Windows上编译代码。当前代码在Linux上成功编译。这是我遵循的步骤来编译Windows 10上的代码。
1)我在Windows 10机器上安装了Cygwin。2)从Cygwin的安装程序包中安装了GCC,G 。3)在环境变量中添加了Cygwin路径。当我编译代码时,它会引发以下错误。
usr/include/boost/asio/detail/posix_signal_blocker.hpp: In constructor ‘boost::asio::detail::posix_signal_blocker::posix_signal_blocker()’:
/usr/include/boost/asio/detail/posix_signal_blocker.hpp:42:25: error: ‘sigfillset’ was not declared in this scope
sigfillset(&new_mask);
^
/usr/include/boost/asio/detail/posix_signal_blocker.hpp: In member function ‘void boost::asio::detail::posix_signal_blocker::block()’:
/usr/include/boost/asio/detail/posix_signal_blocker.hpp:59:27: error: ‘sigfillset’ was not declared in this scope
sigfillset(&new_mask);
^
In file included from /usr/include/boost/asio/detail/signal_set_service.hpp:213:0,
from /usr/include/boost/asio/signal_set_service.hpp:20,
from /usr/include/boost/asio/basic_signal_set.hpp:24,
from /usr/include/boost/asio.hpp:27,
from ../src/app/macl/net/TrxcomInboundReader.h:10,
from ../src/app/macl/net/TrxcomInboundReader.cc:1:
/usr/include/boost/asio/detail/impl/signal_set_service.ipp: In member function boost::system::error_code boost::asio::detail::signal_set_service::add(boost::asio::detail::signal_set_service::implementation_type&, int, boost::system::error_code&)’:
/usr/include/boost/asio/detail/impl/signal_set_service.ipp:266:29: error: ‘sigfillset’ was not declared in this scope
sigfillset(&sa.sa_mask);
^
/usr/include/boost/asio/detail/impl/signal_set_service.ipp:267:44: error: no matching function for call to ‘sigaction::sigaction(int&, sigaction*, int)’
if (::sigaction(signal_number, &sa, 0) == -1)
^
In file included from /usr/include/sys/signal.h:112:0,
from /usr/include/signal.h:6,
from /usr/include/pthread.h:12,
from /usr/lib/gcc/x86_64-pc-cygwin/5.4.0/include/c++/x86_64-pc-cygwin/bits/gthr-default.h:35,
from /usr/lib/gcc/x86_64-pc-cygwin/5.4.0/include/c++/x86_64-pc-cygwin/bits/gthr.h:148,
from /usr/lib/gcc/x86_64-pc-cygwin/5.4.0/include/c++/ext/atomicity.h:35,
from /usr/lib/gcc/x86_64-pc-cygwin/5.4.0/include/c++/bits/basic_string.h:39,
from /usr/lib/gcc/x86_64-pc-cygwin/5.4.0/include/c++/string:52,
from /usr/include/boost/core/demangle.hpp:14,
from /usr/include/boost/core/typeinfo.hpp:119,
from /usr/include/boost/detail/sp_typeinfo.hpp:20,
from /usr/include/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp:27,
from /usr/include/boost/smart_ptr/detail/sp_counted_base.hpp:5 ,
from /usr/include/boost/smart_ptr/detail/shared_count.hpp:29,
from /usr/include/boost/smart_ptr/shared_ptr.hpp:28,
from /usr/include/boost/shared_ptr.hpp:17,
from ../src/app/macl/net/TrxcomInboundReader.h:8,
from ../src/app/macl/net/TrxcomInboundReader.cc:1:
/usr/include/cygwin/signal.h:317:8: note: candidate: sigaction::sigaction()
struct sigaction
^
/usr/include/cygwin/signal.h:317:8: note: candidate expects 0 arguments, 3 provided
/usr/include/cygwin/signal.h:317:8: note: candidate: sigaction::sigaction(const sigaction&)
/usr/include/cygwin/signal.h:317:8: note: candidate expects 1 argument, 3 provided
In file included from /usr/include/boost/asio/detail/signal_set_service.hpp:213:0,
from /usr/include/boost/asio/signal_set_service.hpp:20,
from /usr/include/boost/asio/basic_signal_set.hpp:24,
from /usr/include/boost/asio.hpp:27,
让我知道您的建议。
如果您查看cygwin的signal.h
,您会看到sigaction
和sigfillset
(您的错误消息说缺少了两个功能),在后卫中定义了:
#if __BSD_VISIBLE || __XSI_VISIBLE >= 4
这两个名称被双重编写,以表明您不应该直接将它们设置为自己。因此,请参见features.h
,其中解释了更多。
因此,您需要将这两个内容之一添加到汇编命令中:
-D_XOPEN_SOURCE_EXTENDED
或
-D_GNU_SOURCE
或
-D_BSD_SOURCE
然后,丢失的功能将用于提升。代码中的某个地方可能有一些定义,可以在上述示例中抢占上述示例,如果您在任何可以阻止其工作的地方定义了_POSIX_SOURCE
。
相关文章:
- 错误:未在此范围内声明'reverse'
- 在基于范围的for循环中使用结构化绑定声明
- 错误:"imread"未在此范围内声明
- 我在范围内未声明的错误类有问题
- 未在此范围内声明错误 'xy'
- Socklen_t未在此范围内声明
- 如何从未知视图中声明范围::v3::View 变量
- 错误:'[' 之前预期的非限定 id 和错误:'users'未在此范围内声明
- "Main"已在当前范围内声明
- c++ 变量在宏的扩展中没有在这个范围内声明
- 朋友声明的复杂范围界定规则有什么意义?
- C++ 在编译过程中 strtok 函数 Eclipse 说没有在范围内声明?
- 'num1'未在此范围内声明
- 在此范围内未声明错误"Clreol"
- 如何找到在本地范围内声明的变量的地址?
- 简化在 Pybind11 中为 C++ 模板类生成包装类:模板声明不能出现在块范围内
- C++模板专用化中的声明范围
- 这是有效的C++代码吗?(在声明范围之外使用本地类型)
- 函数声明范围
- 如何在类声明范围内使用“using space::function”