6

In Visual Studio 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) identifier and the compiler wants to use that.

I tried to use #include <limits> as well, but that did not fix the problem.

Is there anyway to get around this?

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
jbolt
  • 688
  • 3
  • 16
  • 37
  • another duplicate [macro “max” requires 2 arguments, but only 1 given](http://stackoverflow.com/questions/518517/macro-max-requires-2-arguments-but-only-1-given) – jrok Jun 27 '12 at 23:51

1 Answers1

13

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>.

Ross Smith
  • 3,719
  • 1
  • 25
  • 22