pthread.h 和 linux/netlink.h的问题

软件和网站开发以及相关技术探讨
回复
头像
zongzw
帖子: 94
注册时间: 2008-03-31 16:12

pthread.h 和 linux/netlink.h的问题

#1

帖子 zongzw » 2008-08-27 19:59

我的代码如下:

代码: 全选

#include <linux/netlink.h>
#include <pthread.h>

int main()
{
        return 0;
}
编译时出现以下错误提示,是怎么回事,感觉比较怪异。

代码: 全选

root@honey-desktop:~# gcc test_pthread.c 
In file included from /usr/include/linux/socket.h:23,
                 from /usr/include/linux/netlink.h:4,
                 from test_pthread.c:2:
/usr/include/linux/uio.h:45: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘iov_length’
/usr/include/linux/uio.h:55: error: expected declaration specifiers or ‘...’ before ‘size_t’
倘若把两个头文件的包含顺序颠倒一下,又是另外一种错误。
本错误在7.04 和Fedora上都有。
上次由 zongzw 在 2008-08-29 12:16,总共编辑 1 次。
头像
zongzw
帖子: 94
注册时间: 2008-03-31 16:12

#2

帖子 zongzw » 2008-08-29 9:02

自己顶一下,为什么会这样?
头像
zongzw
帖子: 94
注册时间: 2008-03-31 16:12

#3

帖子 zongzw » 2008-08-29 19:54

知道了,这样就可以了

代码: 全选

#include <sys/socket.h>
#include <linux/netlink.h> 
#include <pthread.h> 
int main() 
{ 
        return 0; 
}
貌似对linux/netlink.h的引用,需要依赖于sys/socket.h 至于pthread.h和linux/netlink.h之间没有什么关系同时包含没有问题,一开始我提的问题有错误,可能是我那个地方多了手脚以致误认为他们有关系。谢谢了。

编译的时候加上-lpthread连接库
回复