[英]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.