std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n') error when using #include <Windows.h>

StackOverflow https://stackoverflow.com/questions/11235819

  •  17-06-2021
  •  | 
  •  

Domanda

IN VS 2010 Pro I get a compile error stating "expected an identifier" on the max() portion of the command. It seems that in the windows.h header file there is a max(a,b) identified and it wants to use that.

I tried to use the #include as well but that did not fix the problem

Is there anyway to get around this?

È stato utile?

Soluzione

The <windows.h> header has had the min() and max() macros since time immemorial, and they frequently cause problems with C++. Fortunately, you can disable them by adding #define NOMINMAX before including <windows.h>.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top