numeric_limits::max() vs windows.h

Aug 12, 2009 at 3:40pm
hey... im writing on a project which includes <windows.h> and <limits> for numeric_limits...

but when i want to do:
cin.ignore(numeric_limits::max());
it resolves ::max() to the max(a,b)-Macro defined in windows.h so i have to give it 2 parameters... but thats not waht i want...

any suggestions?...
Last edited on Aug 12, 2009 at 3:40pm
Aug 12, 2009 at 3:50pm
#undef max will remove that macro
Aug 12, 2009 at 3:50pm
yeah... I had that problem to. Just undef them:

1
2
3
4
5
6
7
8
#include <windows.h>

#ifdef min
#undef min
#endif
#ifdef max
#undef max
#endif 
Aug 12, 2009 at 4:11pm
There is also a define I think it is:

#define NO_MIN_MAX that prevents windows from dong that.
Aug 12, 2009 at 4:48pm
I prefer #undefining than #defining new macros
Last edited on Aug 12, 2009 at 4:50pm
Aug 12, 2009 at 5:12pm
windows.h predates C++ in the Microsoft world by many years. It is the only file you need to include to get all the junk you need for Windows GUI programming.

The guys at Microsoft recognised this and added a set of switches you can define to turn off parts of it, the most generally useful being WIN32_LEAN_AND_MEAN. Anyway, defining NOMINMAX is the recomended way of switching off min/max macros.
Last edited on Aug 12, 2009 at 5:13pm
Aug 12, 2009 at 9:55pm
thx... i´ll use NOMINMAX...

anyone knows what "Kanji" is?... ther is an macro NOKANJI

:from windows.h :
NOKANJI - Kanji support stuff.
Aug 12, 2009 at 10:04pm
"Kanji" is Japanese for "Chinese Character(s)". It is for Shift-JIS support and the like. You probably don't need it.
Topic archived. No new replies allowed.