CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    May 2008
    Posts
    38

    [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

  2. #2
    Join Date
    Jan 2006
    Location
    Belo Horizonte, Brazil
    Posts
    405

    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)?

  3. #3
    Join Date
    May 2008
    Posts
    38

    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

  4. #4
    Join Date
    Apr 1999
    Posts
    27,449

    Re: mingw with STL problems

    Quote Originally Posted by Cheezewizz View Post
    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
  •  





Click Here to Expand Forum to Full Width

Featured