A problem with WinSock2.h

For a long time now, I have followed the suggestion to use

std::cin.ignore( std::numeric_limits< std::streamsize >::max(), 'n' );

to keep the console window open, as suggested on this site.

But the moment I remove the comment on the <WinSock2.h> header file, such as on this very simple program below,

1
2
3
4
5
6
7
8
9
10
11
#include <iostream>
#include <limits>
//#include <WinSock2.h>

int main( int argc, char* argv[ ])
{

    std::cout << "Press <enter> to exit...";
    std::cin.ignore( std::numeric_limits< std::streamsize >::max(), 'n' );
    return 0;
}


Visual Studio 2010 instantly underlines ::max() and says it expects an identifier, preventing compilation.
So something in WinSock2 is altering something that is defined in Limits?
What is a work-around?
Thank you.
That is because most windows headers define a macro max(), which gets substituted in there. To get rid of it, put the following:

#define NOMINMAX

Before you include any Windows related headers.
Ah, thank you.
Topic archived. No new replies allowed.