Question

How would I go about actually calling std::max? The code won't compile in visual studio 2013, because it takes "max" as the macro.

std::max( ... );

Expects an identifier after the "std::".

Was it helpful?

Solution

You can undefine the macro:

#undef max

Edit: It seems the macros can be safely disabled by putting

#define NOMINMAX

before the header files that define them (most likely windef.h, which you probably include indirectly).

To avoid undefining the macro, you can simply wrap the function in parenthesis

(std::max)(...)

As noted by chris in the comments, function-like macros require the token after the macro name to be a left parenthesis in order to expand. Wrapping the name in parentheses is really just a hack to make the next token a right parenthesis without changing the meaning once you put macros aside.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top