信号 - SIGPIPE未在此范围内声明

时间:2022-05-11 00:09:47

I have a project that i am porting from qt 4 to qt 5. I am getting the error mentioned in title. I have included header file(signal.h). Below is the code .

我有一个项目,我从qt 4移植到qt 5.我收到标题中提到的错误。我已经包含了头文件(signal.h)。以下是代码。

signal(SIGPIPE,SIG_IGN);

I have searched on internet but could not find any reason for this error. also just to note if I place SIGINT in place of SIGPIPE then I don't get any error.

我在互联网上搜索但找不到任何原因导致此错误。还要注意,如果我放置SIGINT代替SIGPIPE,那么我不会收到任何错误。

Any help is appreciated.

任何帮助表示赞赏。

Qt version 5.7 on windows 10

Windows 10上的Qt 5.7版

1 个解决方案

#1


0  

The Microsoft Windows page for "signal" (as of its edit date of 2/12/2018 at least), in its Remarks section, says that the "sig" argument (SIGPIPE) must be one of the constants listed. SIGPIPE is not listed however.

用于“信号”的Microsoft Windows页面(至少在其编辑日期为2/12/2018),在其备注部分中说,“sig”参数(SIGPIPE)必须是列出的常量之一。但是没有列出SIGPIPE。

Looks like not only are you trying to port between different Qt versions, but that you're also trying to port between a Unix-like operating system (like Linux) to the Windows operating system.

看起来你不仅想要在不同的Qt版本之间移植,而且你也试图在类Unix操作系统(如Linux)和Windows操作系统之间移植。

To solve this problem, either:

要解决这个问题,要么:

  1. At least compile time conditionally rip out the SIGPIPE handling code (using something like #ifdef SIGPIPE pre-processor commands to exclude the SIGPIPE code from platforms that don't support SIGPIPE), or
  2. 至少编译时有条件地删除SIGPIPE处理代码(使用类似#ifdef SIGPIPE预处理器命令来从不支持SIGPIPE的平台中排除SIGPIPE代码),或者

  3. Don't try to port your code to any operating systems that don't support SIGPIPE.
  4. 不要尝试将代码移植到任何不支持SIGPIPE的操作系统。

By the way, this seems to have nothing to do with Qt's signals (signals and slots) mechanism (as this question was originally tagged with).

顺便说一句,这似乎与Qt的信号(信号和插槽)机制无关(因为这个问题最初被标记)。

#1


0  

The Microsoft Windows page for "signal" (as of its edit date of 2/12/2018 at least), in its Remarks section, says that the "sig" argument (SIGPIPE) must be one of the constants listed. SIGPIPE is not listed however.

用于“信号”的Microsoft Windows页面(至少在其编辑日期为2/12/2018),在其备注部分中说,“sig”参数(SIGPIPE)必须是列出的常量之一。但是没有列出SIGPIPE。

Looks like not only are you trying to port between different Qt versions, but that you're also trying to port between a Unix-like operating system (like Linux) to the Windows operating system.

看起来你不仅想要在不同的Qt版本之间移植,而且你也试图在类Unix操作系统(如Linux)和Windows操作系统之间移植。

To solve this problem, either:

要解决这个问题,要么:

  1. At least compile time conditionally rip out the SIGPIPE handling code (using something like #ifdef SIGPIPE pre-processor commands to exclude the SIGPIPE code from platforms that don't support SIGPIPE), or
  2. 至少编译时有条件地删除SIGPIPE处理代码(使用类似#ifdef SIGPIPE预处理器命令来从不支持SIGPIPE的平台中排除SIGPIPE代码),或者

  3. Don't try to port your code to any operating systems that don't support SIGPIPE.
  4. 不要尝试将代码移植到任何不支持SIGPIPE的操作系统。

By the way, this seems to have nothing to do with Qt's signals (signals and slots) mechanism (as this question was originally tagged with).

顺便说一句,这似乎与Qt的信号(信号和插槽)机制无关(因为这个问题最初被标记)。