I want to use #define NOMINMAX
in my Visual Studio C++ project using MFC, so that I can use std::min
and std::max
. However, when I put this line in my stdafx.h, I get following compile error:
c:\program files (x86)\windows kits\8.0\include\um\GdiplusTypes.h(475): error C3861: 'min': identifier not found
I am not using GDI+ intentionally, this is something MFC must be doing. Can the issue be fixed somehow, either by removing the GDI+, or by adjusting it to compile?
I don't work on Windows so I'm not used to dealing with this, and I'm not testing this, but I believe that answer is suggesting you do this:
#define NOMINMAX
#include <algorithm>
namespace Gdiplus
{
using std::min;
using std::max;
};
//... your other includes.
This will get the "proper" versions of min
and max
, and make them available without the std::
prefix (which seems to be how it is used in the GdiplusTypes.h
header).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With