Re: WinPCap Problems

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Ok, I found half of the error. I write in C++, not C and the file was
accidentally saved as .c. (Note to self: No more coding at 2 am).

Anyways, there are still problems.

C:\Documents and Settings\root\My Documents\narayan\main.cpp(67) :
error C2065: 'pcap_findalldevs_ex' : undeclared identifier
C:\Documents and Settings\root\My Documents\narayan\main.cpp(67) :
error C2065: 'PCAP_SRC_IF_STRING' : undeclared identifier

Line 67:
if(pcap_findalldevs_ex(PCAP_SRC_IF_STRING, NULL, &devices, errbuf) ==
-1) // find network devices or error

C:\Documents and Settings\root\My Documents\narayan\main.cpp(109) :
error C2065: 'pcap_open' : undeclared identifier
C:\Documents and Settings\root\My Documents\narayan\main.cpp(109) :
error C2065: 'PCAP_OPENFLAG_PROMISCUOUS' : undeclared identifier
C:\Documents and Settings\root\My Documents\narayan\main.cpp(109) :
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

Line 109:
if((handler = pcap_open(udevice->name, 65536,
PCAP_OPENFLAG_PROMISCUOUS, 1000, NULL, errbuf)) == NULL)

Handler is declared as:
pcap_t *handler;

Thanks for your help

Skywing wrote:
Sounds like this is expecting to be compiled as C++ and not plain C.

<shell6@xxxxxxxxx> wrote in message
news:1150517149.191793.42740@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I am starting a project for an internship off on a bad foot. I need to
use WinPCap for my program and even after including pcap.h, I am
getting errors that things are undefined. I completely followed the
tutorial source in the documentation too!

Compiling...
main.c
C:\Documents and Settings\root\My Documents\project\main.c(45) : error
C2143: syntax error : missing ';' before 'type'
C:\Documents and Settings\root\My Documents\project\main.c(46) : error
C2143: syntax error : missing ';' before 'type'
C:\Documents and Settings\root\My Documents\project\main.c(48) : error
C2065: 'captime' : undeclared identifier
C:\Documents and Settings\root\My Documents\project\main.c(48) :
warning C4047: '=' : 'int ' differs in levels of indirection from
'struct tm *'
C:\Documents and Settings\root\My Documents\project\main.c(49) : error
C2065: 'timestr' : undeclared identifier
C:\Documents and Settings\root\My Documents\project\main.c(49) :
warning C4047: 'function' : 'char *' differs in levels of indirection
from 'int '
C:\Documents and Settings\root\My Documents\project\main.c(49) :
warning C4024: 'strftime' : different types for formal and actual
parameter 1
C:\Documents and Settings\root\My Documents\project\main.c(49) :
warning C4047: 'function' : 'const struct tm *' differs in levels of
indirection from 'int '
C:\Documents and Settings\root\My Documents\project\main.c(49) :
warning C4024: 'strftime' : different types for formal and actual
parameter 4
C:\Documents and Settings\root\My Documents\project\main.c(67) :
warning C4013: 'pcap_findalldevs_ex' undefined; assuming extern
returning int
C:\Documents and Settings\root\My Documents\project\main.c(67) : error
C2065: 'PCAP_SRC_IF_STRING' : undeclared identifier
C:\Documents and Settings\root\My Documents\project\main.c(88) : error
C2065: 'd' : undeclared identifier
C:\Documents and Settings\root\My Documents\project\main.c(88) : error
C2223: left of '->description' must point to struct/union
C:\Documents and Settings\root\My Documents\project\main.c(89) : error
C2223: left of '->description' must point to struct/union
C:\Documents and Settings\root\My Documents\project\main.c(94) : error
C2065: 'bool' : undeclared identifier
C:\Documents and Settings\root\My Documents\project\main.c(94) : error
C2146: syntax error : missing ';' before identifier 'go'
C:\Documents and Settings\root\My Documents\project\main.c(94) : error
C2065: 'go' : undeclared identifier
C:\Documents and Settings\root\My Documents\project\main.c(94) : error
C2065: 'false' : undeclared identifier
C:\Documents and Settings\root\My Documents\project\main.c(98) : error
C2065: 'cin' : undeclared identifier
C:\Documents and Settings\root\My Documents\project\main.c(98) :
warning C4552: '>>' : operator has no effect; expected operator with
side-effect
C:\Documents and Settings\root\My Documents\project\main.c(103) : error
C2065: 'true' : undeclared identifier
C:\Documents and Settings\root\My Documents\project\main.c(106) :
warning C4552: '<' : operator has no effect; expected operator with
side-effect
C:\Documents and Settings\root\My Documents\project\main.c(106) : error
C2143: syntax error : missing ')' before ';'
C:\Documents and Settings\root\My Documents\project\main.c(106) : error
C2059: syntax error : ')'
C:\Documents and Settings\root\My Documents\project\main.c(109) :
warning C4013: 'pcap_open' undefined; assuming extern returning int
C:\Documents and Settings\root\My Documents\project\main.c(109) : error
C2065: 'PCAP_OPENFLAG_PROMISCUOUS' : undeclared identifier
C:\Documents and Settings\root\My Documents\project\main.c(109) :
warning C4047: '=' : 'struct pcap *' differs in levels of indirection
from 'int '
Error executing cl.exe.

Here is my include chain:

#include <pcap.h> // pcap functions
#include <iostream.h> // basic io
#include <fstream.h> // file io
#include <string.h> // string funcs

Am I doing something wrong? I placed all of the include files in VC's
include file too....

Thanks.


.



Relevant Pages

  • Re: output unexpected
    ... foo.c:2: warning: function declaration isn't a prototype ... foo.c:2: warning: return type of `main' is not `int' ... foo.c:5: (Each undeclared identifier is reported only once ...
    (comp.lang.c)
  • Re: WinPCap Problems
    ... C2065: 'captime': undeclared identifier ... warning C4024: 'strftime': different types for formal and actual ... indirection from 'int ' ...
    (microsoft.public.win32.programmer.networks)
  • WinPCap Problems
    ... C2065: 'captime': undeclared identifier ... warning C4024: 'strftime': different types for formal and actual ... indirection from 'int ' ...
    (microsoft.public.win32.programmer.networks)
  • Re: WinPCap Problems
    ... C2065: 'captime': undeclared identifier ... warning C4024: 'strftime': different types for formal and actual ... indirection from 'int ' ...
    (microsoft.public.win32.programmer.networks)
  • Re: C++ compile error
    ... hello.C: In function `int main': hello.C:5: error: `cout' undeclared hello.C:5: error: (Each undeclared identifier is reported only once for each function it appears in.) ... cout is part of the 'std' namespace, ... I'm totally puzzled by this complex language when I compile my first program. ...
    (freebsd-questions)