In a recent update to your main.cpp file, you introduced the following preprocessor directive:
#define NOMINMAX #include <Windows.h> #include <algorithm>
This action allows you to utilize the std::max and std::min functions within your code. However, subsequent attempts to employ these functions within other files yield errors such as:
error C2589: '(' : illegal token on right side of '::' error C2059: syntax error : '::'
Despite attempts to define NOMINMAX in these additional files, the issue persists.
The issue lies in the fact that NOMINMAX defines aliases for the Windows min and max macros, overwriting the standard C versions provided by
(std::min)(x, y);
This approach avoids invoking the function-like macros, allowing the standard C versions to be applied.
The above is the detailed content of Why Do I Get Errors When Using std::min/max with #define NOMINMAX?. For more information, please follow other related articles on the PHP Chinese website!