sys / types.h和linux / types.h的重新声明冲突

时间:2012-02-07 11:50:22

标签: c++ linux

我的程序有编译错误:

/usr/include/sys/types.h:46: error: conflicting declaration ‘typedef __loff_t loff_t’
/usr/include/linux/types.h:30: error: ‘loff_t’ has a previous declaration as ‘typedef __kernel_loff_t loff_t’
/usr/include/sys/types.h:62: error: conflicting declaration ‘typedef __dev_t dev_t’
/usr/include/linux/types.h:13: error: ‘dev_t’ has a previous declaration as ‘typedef __kernel_dev_t dev_t’
/usr/include/time.h:105: error: conflicting declaration ‘typedef void* timer_t’
/usr/include/linux/types.h:22: error: ‘timer_t’ has a previous declaration as ‘typedef __kernel_timer_t timer_t’
/usr/include/sys/types.h:198: error: conflicting declaration ‘typedef long int int64_t’
/usr/include/linux/types.h:98: error: ‘int64_t’ has a previous declaration as ‘typedef __s64 int64_t’
/usr/include/sys/types.h:204: error: conflicting declaration ‘typedef long unsigned int u_int64_t’
/usr/include/linux/types.h:97: error: ‘u_int64_t’ has a previous declaration as ‘typedef __u64 u_int64_t’
/usr/include/sys/select.h:78: error: conflicting declaration ‘typedef struct fd_set fd_set’
/usr/include/linux/types.h:12: error: ‘fd_set’ has a previous declaration as ‘typedef struct __kernel_fd_set fd_set’
/usr/include/sys/types.h:235: error: conflicting declaration ‘typedef __blkcnt_t blkcnt_t’
/usr/include/linux/types.h:124: error: ‘blkcnt_t’ has a previous declaration as ‘typedef long unsigned int blkcnt_t’

在我的代码中,我根本没有包含任何types.h,因此我怀疑它必须是那些包含.hsys/types.h的第三方linux/type.h文件。

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

这似乎是一个常见问题,但提到的解决方案却有很多不同。

一个合理的解决方案是在libpcan.h或Qt标头之前自己包含两个标头中的一个。我无法弄清楚哪一个,所以你必须尝试两者。如果失败,请尝试在两个订单中同时包含两者。