Dealing with Max Macro Collision in Windows.h and Std
Windows.h includes WinDef.h, which defines the min and max macros. This can conflict with the max macro defined in std, leading to compilation errors.
To resolve this issue, you can use the following workaround:
#define NOMINMAX #include <Windows.h> #include <iostream> using std::cin; using std::cout; void Foo() { int delay = 0; do { if (cin.fail()) { cin.clear(); cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); } cout << "Enter number of seconds between submissions: "; } while (!(cin >> delay) || delay == 0); }
By defining the NOMINMAX macro, you suppress the min and max definitions in WinDef.h, allowing you to use the max macro from std without any conflicts.
The above is the detailed content of How to Resolve Max Macro Collisions Between Windows.h and std::max?. For more information, please follow other related articles on the PHP Chinese website!