|
-
January 5th, 2010, 10:46 AM
#1
[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
-
January 5th, 2010, 11:28 AM
#2
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)?
-
January 5th, 2010, 01:01 PM
#3
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
-
January 5th, 2010, 01:28 PM
#4
Re: mingw with STL problems
 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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|