Guy Harris wrote: > > On Tue, Dec 03, 2002 at 09:35:14AM -0000, Graham Bloice wrote: > > According to Source Navigator (and windows find) the only ?? places > > including winsock.h are Packet32.h and BPF.h in WinPCap, > > Unfortunately, one or both of those are included by pcap.h, and we have > to include pcap.h in all files that use libpcap. > ...several files *HAVE* to have winsock2.h included in them
if inclusion of pcap.h causes a problem, then I would recommend that there should be a simple wrapper file... the contents being similar to the following: #ifndef _PCAP_WRAPPER # define _PCAP_WRAPPER # ifdef HAVE_PCAP_H # ifdef HAVE_WINSOCK2_H # include <winsock2.h> # endif # include "pcap.h" # endif #endif In some ways, I don't like wrappers, but when you're dealing with somebone else's library, it can make life a bit easier... Joerg Mayer wrote: > by ifndef XXX define XXX includefile endif. If things are the same with > real windows, shouldn't the problem be solvable by reordering the includes? That is the way to get around it on my copy of real (2k) windows... I assume the various windows flavors work similarly... Rather than swap the order, the easiest approach would be to simply try to include winsock2.h before winsock.h and let the #ifndef in winsock2.h stop it from being included again... this is especially true when the inclusion of winsock2.h is included in a header file that might be included through different methods. If it is in a c file, the inclusion of winsock2.h could potentially be removed...
