error C2065: 'pcap_open' : undeclared identifier

 

错误:

1.cpp
E:\Program Files\Microsoft Visual Studio\MyProjects\winpcap3\1.cpp(55) : error C2065: 'pcap_open' : undeclared identifier
E:\Program Files\Microsoft Visual Studio\MyProjects\winpcap3\1.cpp(57) : error C2065: 'PCAP_OPENFLAG_PROMISCUOUS' : undeclared identifier
E:\Program Files\Microsoft Visual Studio\MyProjects\winpcap3\1.cpp(61) : error C2440: '=' : cannot convert from 'int' to 'struct pcap *'
        Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
E:\Program Files\Microsoft Visual Studio\MyProjects\winpcap3\1.cpp(86) : error C2065: 'time_t' : undeclared identifier
E:\Program Files\Microsoft Visual Studio\MyProjects\winpcap3\1.cpp(86) : error C2146: syntax error : missing ';' before identifier 'local_tv_sec'
E:\Program Files\Microsoft Visual Studio\MyProjects\winpcap3\1.cpp(86) : error C2065: 'local_tv_sec' : undeclared identifier
E:\Program Files\Microsoft Visual Studio\MyProjects\winpcap3\1.cpp(90) : error C2065: 'localtime' : undeclared identifier
E:\Program Files\Microsoft Visual Studio\MyProjects\winpcap3\1.cpp(90) : error C2440: '=' : cannot convert from 'int' to 'struct packet_handler::tm *'
        Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
E:\Program Files\Microsoft Visual Studio\MyProjects\winpcap3\1.cpp(91) : error C2065: 'strftime' : undeclared identifier
执行 cl.exe 时出错.

 

 

原因:有些头文件没有加进来,所以会有错误。

 

解决办法:

因为winpcap现在增加了远程捕获的功能,

在pcap_findalldevs_ex和pcap_open函数中增加了远程主机身份验证的参数struct   pcap_rmtauth   *     auth,所以将两个函数的定义转移到remote-ext.h中去了

所以现在使用这两个参数的时候需要包含

#include   "remote-ext.h "

#include "time.h"

 



 

你可能感兴趣的:(c,struct,Microsoft)