c++ - siginfo_t 尚未声明 : caused by inclusion of a thrift header

标签 c++ include thrift c-preprocessor

这是我的main.cpp

#include <thrift/protocol/TProtocol.h>

#define <sys/wait.h>

int main(int argc, char** argv) {
  return 0;
}

当我运行 g++ main.cpp 时,我得到:

In file included from main.cpp:2:0:
/usr/include/x86_64-linux-gnu/sys/wait.h:148:52: error: ‘siginfo_t’ has not been declared
 extern int waitid (idtype_t __idtype, __id_t __id, siginfo_t *__infop,
                                                    ^

如果我颠倒包含的顺序或删除其中任何一个包含,编译就会成功。这两者之间存在一些我不理解的相互作用。仅当 thrift/protocol/TProtocol.h 包含在 before sys/wait.h 时,编译才会失败。

我想看看预处理后的输出是什么样子的,所以我运行 g++ main.cpp -E -o preprocessed.p; grep -irn -B 10 "siginfo_t"preprocessed.p;

我得到:

38168-   } _sigpoll;
38169-
38170-
38171- struct
38172-   {
38173-     void *_call_addr;
38174-     int _syscall;
38175-     unsigned int _arch;
38176-   } _sigsys;
38177-      } _sifields;
38178:  } siginfo_t ;
--
38408-extern int gsignal (int __sig) throw ();
38409-
38410-
38411-
38412-
38413-extern void psignal (int __sig, const char *__s);
38414-
38415-
38416-
38417-
38418:extern void psiginfo (const siginfo_t *__pinfo, const char *__s);
--
38476-# 24 "/usr/include/x86_64-linux-gnu/bits/sigaction.h" 3 4
38477-struct sigaction
38478-  {
38479-
38480-
38481-    union
38482-      {
38483-
38484- __sighandler_t sa_handler;
38485-
38486: void (*sa_sigaction) (int, siginfo_t *, void *);
--
38528-
38529-extern int sigwait (const sigset_t *__restrict __set, int *__restrict __sig)
38530-     __attribute__ ((__nonnull__ (1, 2)));
38531-
38532-
38533-
38534-
38535-
38536-
38537-extern int sigwaitinfo (const sigset_t *__restrict __set,
38538:   siginfo_t *__restrict __info) __attribute__ ((__nonnull__ (1)));
38539-
38540-
38541-
38542-
38543-
38544-
38545-extern int sigtimedwait (const sigset_t *__restrict __set,
38546:    siginfo_t *__restrict __info,
--
39462-extern __pid_t wait (void * __stat_loc);
39463-# 125 "/usr/include/x86_64-linux-gnu/sys/wait.h" 3 4
39464-extern __pid_t waitpid (__pid_t __pid, int *__stat_loc, int __options);
39465-# 135 "/usr/include/x86_64-linux-gnu/sys/wait.h" 3 4
39466-# 1 "/usr/include/x86_64-linux-gnu/bits/siginfo.h" 1 3 4
39467-# 24 "/usr/include/x86_64-linux-gnu/bits/siginfo.h" 3 4
39468-# 1 "/usr/include/x86_64-linux-gnu/bits/wordsize.h" 1 3 4
39469-# 25 "/usr/include/x86_64-linux-gnu/bits/siginfo.h" 2 3 4
39470-# 136 "/usr/include/x86_64-linux-gnu/sys/wait.h" 2 3 4
39471-# 148 "/usr/include/x86_64-linux-gnu/sys/wait.h" 3 4
39472:extern int waitid (idtype_t __idtype, __id_t __id, siginfo_t *__infop,

在我看来,siginfo_t 在第 38171-38178 行声明/定义的。为什么这不足以用于第 39472 行?

信息:

  • Ubuntu 14.04
  • Thrift 0.9.1,配置有 ./configure --prefix=/usr/local/--with-c_glib=no --enable-tests=no --with-python=no

最佳答案

这是一个错误,现已修复:

https://github.com/apache/thrift/commit/f4e6e62ea091b94322ecc99756269dbee1c06380

apache::thrift::protocol 命名空间包含一个系统头文件 (sys/param.h)。

关于c++ - siginfo_t 尚未声明 : caused by inclusion of a thrift header,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24211656/

相关文章:

cassandra - 在 Cassandra Docker 中启用 Thrift

c++ - 为什么这种类型的双关语不是未定义的行为?

javascript - 在 NPAPI 插件对象上调用方法会重新生成插件

c++ - 我应该包括每个标题吗?

c++在分配变量时未处理的异常访问冲突

php - 将参数传递给 php include/require 构造

css - 无法让页面特定的 CSS 仅在 Rails 中的一个指定页面上工作

Django 模板 - 更改 'include' 模板的上下文

java - 如何创建TBase类实例

python - Tchannel 服务器代码不工作。 (Python 和 Node.js)