farshid’s Post

Why use NOMINMAX? #ifndef NOMINMAX #define NOMINMAX #endif #include <windows.h> #include <algorithm> // Now std::min/std::max work fine --- When you include the Windows header <windows.h>, by default it defines two macros: #define min(a, b) ... #define max(a, b) ... These macros conflict with the standard C++ std::min and std::max functions, which can cause unexpected errors or make it hard to use templates and algorithms cleanly. By defining NOMINMAX before including <windows.h>, you prevent Windows from defining these macros, so you can use std::min and std::max safely.

To view or add a comment, sign in

Explore content categories