i recently added:
#define NOMINMAX
#include <Windows.h>
#include <algorithm>
to my main.cpp in order to use
std::max( x , x ); // x is just a placeholder and not actual anything
std::min( x , x );
but i can't use std::max()/std::min()
in other files.
error C2589: '(' : illegal token on right side of '::'
error C2059: syntax error : '::'
i tried to add #define NOMINMAX
in my other files, but fails. what is the clue?
i looked around before asking, but i don't understand the answer Possible problems with NOMINMAX on Visual C++
windows.h
and uses the algorithm versions should have it defined before the include if it isn't defined already.<windows.h>
as well without definingNOMINMAX
previously (maybe indirectly through some other header)?#undef NOMINMAX
after the#include <Windows.h>
. This would reduce so much confusion. same for#define WIN32_LEAN_AND_MEAN
.#define NOMINMAX
acts as an "argument" to Windows.h in a funny way. and#undef NOMINMAX
is like cleaning up the stack afterwards, in a funny way. Future includes always thank you for it by not spamming warnings.