冲突redeclaration sys /类型。h和linux / types.h

时间:2021-05-03 16:13:12

I have compilation errors for my program:

我的程序有编译错误:

/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’

In my code I didn't include any types.h at all, so I suspect it must be those third party .h files that have included sys/types.h and linux/type.h.

在我的代码中,我没有包含任何类型。h,所以我猜肯定是那些第三方的。h文件包含了sys/types。h和linux / type.h。

How shall I fix this issue?

我该如何解决这个问题?

1 个解决方案

#1


1  

It seems to be a common problem, and yet there are widely different solutions mentioned.

这似乎是一个常见的问题,但也有许多不同的解决方案。

One reasonable solution is to include one of the two headers yourself, before libpcan.h or the Qt headers. I can't figure out which one, so you'll have to try both. If this fails, try to include both, and in both orders.

一个合理的解决方案是在libpcan之前,自己包含两个header中的一个。h或Qt标题。我想不出是哪一个,所以你们两个都得试试。如果失败了,试着将两者都包括进来,并在两个订单中。

#1


1  

It seems to be a common problem, and yet there are widely different solutions mentioned.

这似乎是一个常见的问题,但也有许多不同的解决方案。

One reasonable solution is to include one of the two headers yourself, before libpcan.h or the Qt headers. I can't figure out which one, so you'll have to try both. If this fails, try to include both, and in both orders.

一个合理的解决方案是在libpcan之前,自己包含两个header中的一个。h或Qt标题。我想不出是哪一个,所以你们两个都得试试。如果失败了,试着将两者都包括进来,并在两个订单中。