c++ - Unable to compile PCAP Program in Visual studio -


following code retrieve mac addresses airpcap adapter. facing issues when executing program: please me in resolving error.

#include <stdio.h> #include <conio.h> #include "packet32.h" #include <ntddndis.h> #include "stdafx.h" #define max_num_adapter 10 char        adapterlist[max_num_adapter][1024];  int main() {     lpadapter   lpadapter = 0;     int         i;     dword       dwerrorcode;     wchar       adaptername[8192];     wchar       *temp,*temp1;     int         adapternum=0,open;     ulong       adapterlength;     ppacket_oid_data  oiddata;     boolean     status;      //     // obtain name of adapters installed on machine     //      printf("packet.dll test application. library version:%s\n", packetgetversion());      printf("adapters installed:\n");     i=0;          adapterlength = sizeof(adaptername);      if(packetgetadapternames(adaptername,&adapterlength)==false){         printf("unable retrieve list of adapters!\n");         return -1;     }     temp=adaptername;     temp1=adaptername;      while ((*temp!='\0')||(*(temp-1)!='\0'))     {         if (*temp=='\0')          {             memcpy(adapterlist[i],temp1,temp-temp1);             temp1=temp+1;             i++;         }         temp++;     }      adapternum=i;     (i=0;i<adapternum;i++)         printf("\n%d- %s\n",i+1,adapterlist[i]);     printf("\n");            {         printf("select number of adapter open : ");         scanf_s("%d",&open);         if (open>adapternum) printf("\nthe number must smaller %d",adapternum);      } while (open>adapternum);       //     // open selected adapter     //      lpadapter =   packetopenadapter(adapterlist[open-1]);      if (!lpadapter || (lpadapter->hfile == invalid_handle_value))     {         dwerrorcode=getlasterror();         printf("unable open adapter, error code : %lx\n",dwerrorcode);           return -1;     }         //      // allocate buffer mac adress     //      oiddata = (ppacket_oid_data)malloc(6 + sizeof(packet_oid_data));     if (oiddata == null)      {         printf("error allocating memory!\n");         packetcloseadapter(lpadapter);         return -1;     }      //      // retrieve adapter mac querying nic driver     //      oiddata->oid = oid_802_3_current_address;      oiddata->length = 6;     zeromemory(oiddata->data, 6);      status = packetrequest(lpadapter, false, oiddata);     if(status)     {         printf("the mac address of adapter %.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n",             (oiddata->data)[0],             (oiddata->data)[1],             (oiddata->data)[2],             (oiddata->data)[3],             (oiddata->data)[4],             (oiddata->data)[5]);     }     else     {         printf("error retrieving mac address of adapter!\n");     }      free(oiddata);     packetcloseadapter(lpadapter);     return (0); } 

following errors:

1>------ build started: project: qqq, configuration: release win32 ------ 1>build started 5/29/2015 3:10:00 pm. 1>initializebuildstatus: 1>  touching "release\qqq.unsuccessfulbuild". 1>clcompile: 1>  outputs up-to-date. 1>  ppp.cpp 1>ppp.cpp(35): warning c4627: '#include <conio.h>': skipped when looking precompiled header use 1>          add directive 'stdafx.h' or rebuild precompiled header 1>ppp.cpp(36): warning c4627: '#include "packet32.h"': skipped when looking precompiled header use 1>          add directive 'stdafx.h' or rebuild precompiled header 1>ppp.cpp(37): warning c4627: '#include <ntddndis.h>': skipped when looking precompiled header use 1>          add directive 'stdafx.h' or rebuild precompiled header 1>ppp.cpp(44): error c2065: 'lpadapter' : undeclared identifier 1>ppp.cpp(44): error c2146: syntax error : missing ';' before identifier 'lpadapter' 1>ppp.cpp(44): error c2065: 'lpadapter' : undeclared identifier 1>ppp.cpp(46): error c2065: 'dword' : undeclared identifier 1>ppp.cpp(46): error c2146: syntax error : missing ';' before identifier 'dwerrorcode' 1>ppp.cpp(46): error c2065: 'dwerrorcode' : undeclared identifier 1>ppp.cpp(47): error c2065: 'wchar' : undeclared identifier 1>ppp.cpp(47): error c2146: syntax error : missing ';' before identifier 'adaptername' 1>ppp.cpp(47): error c2065: 'adaptername' : undeclared identifier 1>ppp.cpp(48): error c2065: 'wchar' : undeclared identifier 1>ppp.cpp(48): error c2065: 'temp' : undeclared identifier 1>ppp.cpp(48): error c2065: 'temp1' : undeclared identifier 1>ppp.cpp(50): error c2065: 'ulong' : undeclared identifier 1>ppp.cpp(50): error c2146: syntax error : missing ';' before identifier 'adapterlength' 1>ppp.cpp(50): error c2065: 'adapterlength' : undeclared identifier 1>ppp.cpp(51): error c2065: 'ppacket_oid_data' : undeclared identifier 1>ppp.cpp(51): error c2146: syntax error : missing ';' before identifier 'oiddata' 1>ppp.cpp(51): error c2065: 'oiddata' : undeclared identifier 1>ppp.cpp(52): error c2065: 'boolean' : undeclared identifier 1>ppp.cpp(52): error c2146: syntax error : missing ';' before identifier 'status' 1>ppp.cpp(52): error c2065: 'status' : undeclared identifier 1>ppp.cpp(58): error c3861: 'packetgetversion': identifier not found 1>ppp.cpp(63): error c2065: 'adapterlength' : undeclared identifier 1>ppp.cpp(63): error c2065: 'adaptername' : undeclared identifier 1>ppp.cpp(63): error c2070: ''unknown-type'': illegal sizeof operand 1>ppp.cpp(65): error c2065: 'adaptername' : undeclared identifier 1>ppp.cpp(65): error c2065: 'adapterlength' : undeclared identifier 1>ppp.cpp(65): error c2065: 'false' : undeclared identifier 1>ppp.cpp(65): error c3861: 'packetgetadapternames': identifier not found 1>ppp.cpp(69): error c2065: 'temp' : undeclared identifier 1>ppp.cpp(69): error c2065: 'adaptername' : undeclared identifier 1>ppp.cpp(70): error c2065: 'temp1' : undeclared identifier 1>ppp.cpp(70): error c2065: 'adaptername' : undeclared identifier 1>ppp.cpp(72): error c2065: 'temp' : undeclared identifier 1>ppp.cpp(72): error c2065: 'temp' : undeclared identifier 1>ppp.cpp(72): fatal error c1903: unable recover previous error(s); stopping compilation 1>  qqq.cpp 1>qqq.cpp(36): warning c4627: '#include <conio.h>': skipped when looking precompiled header use 1>          add directive 'stdafx.h' or rebuild precompiled header 1>qqq.cpp(155): error c3861: '_kbhit': identifier not found 1>qqq.cpp(197): error c2440: '=' : cannot convert 'pvoid' 'char *' 1>          conversion 'void*' pointer non-'void' requires explicit cast 1>qqq.cpp(202): error c3861: '_kbhit': identifier not found 1> 1>build failed. 1> 1>time elapsed 00:00:00.33 ========== build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== 

i facing undeclared identifier issue. please guide me on resolving issue.

stdafx.h needs included first before other headers. requirement of vc++ compiler. if stdafx.h included after other header files header files skipped compiler. when happens unable resolve symbols declared in headers.


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -