[RESOLVED] mingw with STL problems
Hey guys. I've got some code using the windows packet capture library (winpcap) that works fine when compiled with Visual Studio, but just won't compile with Mingw. After a few tweaks I think I've finally found the root of the problem but can't for the life of me figure out how to fix it. It's when both pcap.h and any STL container class header is included...
The simplest way I found to reproduce the issue I'm having is with the following code...
Code:
#include <pcap.h>
#include <windows.h>
#include <stdio.h>
int main(int argc, char* pszArgs[])
{
printf("Testing");
return 0;
}
Compiled with
Code:
g++ blah.cpp -o blah.exe -IWpd\Include
it compiles fine. However adding for example #include <deque> and trying to compile with same arguments results in it going mental and complaining about errors like '::snprintf has not ben declared'. Removing either of these
Code:
#include <pcap.h>
#include <deque>
and it will compile. Anyone with any ideas/comments? Any thoughts much appreciated :)
Re: mingw with STL problems
Just some ideas which might help identify the problem...
Have you tried adding the three headers in different orders? If you #include <cstdio> instead of #include <stdio.h> does it change anything (cstdio is the corresponding C++ header of stdio.h)?
Re: mingw with STL problems
Gah, lol yep it was as simple as that. Well, that's embarassing. Changing my original code's include order to
Code:
#include <stdio.h>
#include <windows.h>
#include <deque>
#include <process.h>
#include <pcap.h>
sorted it out. Compiles fine now, anyone care to explain why? Cheers ltcmelo :)
Re: mingw with STL problems
Quote:
Originally Posted by
Cheezewizz
Gah, lol yep it was as simple as that. Well, that's embarassing. Changing my original code's include order to
Code:
#include <stdio.h>
#include <windows.h>
#include <deque>
#include <process.h>
#include <pcap.h>
sorted it out. Compiles fine now, anyone care to explain why? Cheers ltcmelo :)
The simplest explanation is that there is some af conflict going on between two or more headers, where the same symbol is defined or declared in each of the headers diffrently.
Regards,
Paul McKenzie