WINXP SP2 VS2005 下编译wireshark-1.10.0rc2出现以下错误
capture_win_ifnames.c
capture_win_ifnames.c(236) : error C2065: 'IF_MAX_STRING_SIZE' : undeclared identifier
capture_win_ifnames.c(236) : error C2057: expected constant expression
capture_win_ifnames.c(236) : error C2466: cannot allocate an array of constant size 0
capture_win_ifnames.c(236) : error C2133: 'wName' : unknown size
capture_win_ifnames.c(258) : error C2146: syntax error : missing ')' before identifier 'InterfaceLuid'
capture_win_ifnames.c(258) : error C2081: 'PNET_LUID' : name in formal parameter list illegal
capture_win_ifnames.c(258) : error C2146: syntax error : missing ';' before identifier 'InterfaceLuid'
capture_win_ifnames.c(258) : error C2059: syntax error : ')'
capture_win_ifnames.c(258) : error C2065: 'InterfaceLuid' : undeclared identifier
capture_win_ifnames.c(259) : error C2143: syntax error : missing ';' before 'type'
capture_win_ifnames.c(262) : error C2275: 'ProcAddr_CIG2L' : illegal use of this type as an expression
capture_win_ifnames.c(258) : see declaration of 'ProcAddr_CIG2L'
capture_win_ifnames.c(262) : error C2146: syntax error : missing ';' before identifier 'proc_ConvertInterfaceGuidToLuid'
capture_win_ifnames.c(262) : error C2065: 'proc_ConvertInterfaceGuidToLuid' : undeclared identifier
capture_win_ifnames.c(262) : warning C4047: '=' : 'int' differs in levels of indirection from 'ProcAddr_CIG2L'
capture_win_ifnames.c(263) : warning C4047: '!=' : 'int' differs in levels of indirection from 'void *'
capture_win_ifnames.c(264) : error C2065: 'ProcAddr_CIL2A' : undeclared identifier
capture_win_ifnames.c(264) : error C2146: syntax error : missing ';' before identifier 'Proc_ConvertInterfaceLuidToAlias'
capture_win_ifnames.c(264) : error C2065: 'Proc_ConvertInterfaceLuidToAlias' : undeclared identifier
capture_win_ifnames.c(264) : error C2146: syntax error : missing ';' before identifier 'GetProcAddress'
capture_win_ifnames.c(265) : warning C4047: '!=' : 'int' differs in levels of indirection from 'void *'
capture_win_ifnames.c(267) : error C2065: 'NET_LUID' : undeclared identifier
capture_win_ifnames.c(267) : error C2146: syntax error : missing ';' before identifier 'InterfaceLuid'
capture_win_ifnames.c(268) : error C2063: 'proc_ConvertInterfaceGuidToLuid' : not a function
capture_win_ifnames.c(271) : error C2063: 'Proc_ConvertInterfaceLuidToAlias' : not a function
capture_win_ifnames.c(304) : warning C4034: sizeof returns 0
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 8\VC\BIN\cl.EXE"' : return code '0x2'
Stop.
原因是没有安装SDK,找不到ifdef.h
解决方法有2种
1.安装SDK
2.修改capture_win_ifnames.c
#ifndef NDIS_IF_MAX_STRING_SIZE
#ifndef IF_MAX_STRING_SIZE
#define IF_MAX_STRING_SIZE 256
#endif
#define NDIS_IF_MAX_STRING_SIZE IF_MAX_STRING_SIZE /* =256 in <ifdef.h> */
#endif
#ifndef NET_LUID
typedef union _NET_LUID {
ULONG64 Value;
struct {
ULONG64 Reserved :24;
ULONG64 NetLuidIndex :24;
ULONG64 IfType :16;
} Info;
} NET_LUID, *PNET_LUID;
#endif
编译正常。