简体   繁体   English

重新声明sys / types.h和linux / types.h

[英]conflicting redeclaration of sys/types.h and linux/types.h

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 . 在我的代码中,我根本不包含任何types.h ,因此我怀疑它必须是包含sys/types.hlinux/type.h第三方.h文件。

How shall I fix this issue? 我该如何解决这个问题?

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. 一种合理的解决方案是在libpcan.h或Qt头之前,自己包括两个头之一。 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. 如果失败,请尝试同时包含两个和两个订单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM