c++cwindowsc-preprocessor

Strange C++ errors with code that has min()/max() calls


I'm seeing strange errors when my C++ code has min() or max() calls. I'm using Visual C++ compilers.


Solution

  • Check if your code is including the windows.h header file and either your code or other third-party headers have their own min()/max() definitions. If yes, then prepend your windows.h inclusion with a definition of NOMINMAX like this:

    #define NOMINMAX
    #include <windows.h>