[英]Trouble with compiling errors
我遇到了一些我无法弄清的编译错误,尽管我确信它们很愚蠢,但我找不到其他途径可以帮助我的答案。
问题1 :(这些是TCP协议的一部分)
error: ‘TH_SYN’ undeclared (first use in this function)
error: ‘TH_ACK’ undeclared (first use in this function)
tcp.tcph_flags = TH_SYN;
tcp.tcph_flags = TH_ACK;
问题2:
error: conversion to non-scalar type requested
const int one = 1;
char buffer[PCKT_LEN];
struct sockaddr_in sin;
struct ipheader ip;
struct tcpheader tcp;
ip = (struct ipheader) buffer; /* ERROR POINTS HERE */
tcp = (struct tcpheader) buffer + ip.iph_ihl *4; /* AND HERE */
问题三:
warning: assignment makes integer from pointer without a cast
case 'i': dip = inet_addr(optarg);
dstip = (optarg); /* ERROR POINTS TO THIS LINE */
break;
现在,我希望我已经复制了足够的有关错误的信息,以便为您提供帮助,但是如果我遗漏了一些信息,请告诉我。 对于问题1,我相信我缺少某种头文件,但我不知道该头文件。 问题2和3是指针问题,但是我不确定为什么它们不正确。 提前致谢 :)
TH_SYN
和TH_ACK
的标头。 在我的系统上是netinet/tcp.h
ipheader
和tcpheader
转换为指针 strtoul
,但我不能确定 对于问题1,您需要
#include <netinet/tcp.h>
对于问题2, struct ipheader
应该是struct ipheader *
在你的宣言,并投两个,以及struct tcpheader
应该是struct tcpheader *
对于问题3,optarg是一个指针,需要取消引用,因此将其称为*optarg
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.