麻烦编译和使用netinet / tcp.h与-std = c99

时间:2014-08-28 11:22:46

标签: c

#include<stdint.h>
#include<netinet/ip.h>
#include<netinet/tcp.h>


int main()
{
        struct tcphdr *tcpHdr = ((struct tcphdr*)NULL) ;
        struct iphdr *ipHdr = ((struct iphdr*)NULL);

        uint8_t offset = (unsigned int)(tcpHdr->doff)*4;
        uint16_t port =  tcpHdr->dest;

        unsigned int hdr_len = (ipHdr->ihl)*4;

        return 0;
}
编译后

gcc -std = c99 test1.c:

test1.c: In function ‘main’:
test1.c:13:40: error: dereferencing pointer to incomplete type
test1.c:14:25: error: dereferencing pointer to incomplete type

问题:

1)。它没有给struct iphdr

带来任何错误

2)。如果我不包括-std = c99,它编译并正常工作。

0 个答案:

没有答案