Once in a while, bored to fall into their own dug pit.
Previous Blog "Vs2015–win32 project configuration of some ideas of the algorithm Min/max and Windows Min/max macro conflict" wrote how to deal with algorithm in Std:min and windows in the conflict of Min, We used the preprocessor Nominmax.
The standard library <algorithm>
defines two template functions Std::min () and Std::max () in the header.
It is commonly used to calculate the minimum and maximum values for a pair of values. Unfortunately, they are not available in Visual C + + because these function templates are not defined. The reason is that the name min and Max <windows.h>
are in conflict with the traditional Min/max macro definition in. To solve this problem, Visual C + + defines two other templates with the same functionality: _cpp_min () and _cpp_max (). We can use them instead of std::min () and Std::max (). In order to disable the Min/max macro definition in Visual C + +, you can precede the <windows.h>
header file with the following: Nominmax
But when it comes to GDI, another error occurs:
GdiplusTypes.h (470): Error C3861: ' min ': identifier not found
At this time I was confused, what happened?
Baidu has a lap, all is the answer of deceptive, all told me preprocessing definition Nominmax.
But how to do all is wrong, this just dawned, originally here is need min, we can't undef off.
So before referring to GDI's related header files, redefine min:
#ifndef min#define min#endif#include <GdiPlus.h>
The premise of this is that you want to solve the algorithm in Std::min and windows in the conflict, or preprocessing: Nominmax, or this:
#undef min
Vs2015--win32 Some ideas of the project configuration GdiplusTypes.h (470): Error C3861: ' min ': identifier not found