limits and windows.h a no no?

Started by
1 comment, last by Matsen 20 years, 6 months ago
limits doesn't seem to like windows.h, or vice versa. For some strange reason, this does not compile:

#include <windows.h>
#include <limits>

int main()
{
	std::numeric_limits<char>::max();
}
 
The compiler (.NET 2003 standard) says: : warning C4003: not enough actual parameters for macro 'max' : error C2589: '(' : illegal token on right side of '::' : error C2143: syntax error : missing ';' before '::' If I don't include windows.h, it compiles just fine. What's wrong?! Edit: < > [edited by - Matsen on October 8, 2003 4:11:35 AM]
Advertisement
Windows defines macros named min and max (which I think should be named MIN and MAX). Define NOMINMAX before including windows.h to prevent this.

~nz

// Website // Google // GameDev // NeHe // MSDN // OpenGL Extensions //
~neoztar "Any lock can be picked with a big enough hammer"my website | opengl extensions | try here firstguru of the week | msdn library | c++ faq lite
#define NOMINMAX#include <windows.h>#include <limits>int main(){	std::numeric_limits::max();} 


Edit: Thanks neoztar

[edited by - Matsen on October 8, 2003 4:20:36 AM]

This topic is closed to new replies.

Advertisement