I’m having a problem with std::max. I can’t figure it out.
int border = 35;
int myInt = 2;
int myOtherInt = 3;
int z = std::max(myInt + 2 * border, myOtherInt + 2 * border);
I’ve included the algorithm standard header. When I mouse over max, I am getting:
Error: expected an identifier
And a compile errors of:
error C2589:
'(': illegal token on right side of'::'
error C2059: syntax error :'::'
What is wrong?
Hazarding a guess, since you’re using VC++ – put this before any
#includes:windows.hdefines macros namedminandmaxlike so:The Windows SDK has contained these macros since before C++ was standardized, but because they obviously play havoc with the C++ standard library, one can define the
NOMINMAXmacro to prevent them from being defined.As a rule, if you’re using C++ (as opposed to C) and including
windows.h, always defineNOMINMAXfirst.