#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,它编译并正常工作。