Standard library conflicts with MFC
May 5th, 2008
Often includes from the standard library conflicts with the MFC library. Microsoft can’t do anything about it because of backward compatibility. The conflict are the functions min() and max(). The only thing that is done is to check for a preprocessor value NOMINMAX. If you define this for the whole project, conflicts should be avoided.
It is done in the Project | Settings, and the tab C/C++. Add the NOMINMAX definition to the “Preprocessor definitions” area.
The problem is caused by conflicting definitions of min and max. Min and max are defined as macros in Windef.h as follows:
#ifndef NOMINMAX #ifndef max #define max(a,b) (((a) > (b)) ? (a) : (b)) #endif #ifndef min #define min(a,b) (((a) < (b)) ? (a) : (b)) #endif #endif /* NOMINMAX */





