Article ID: 143208 - View products that this article applies to.
This article was previously published under Q143208
A windows-based program that uses the Standard Template Library (STL) will not compile, and it generates several invalid parameter and syntax errors.
The problem is caused by conflicting definitions of min and max. Min and max are defined as macros in Windef.h as follows:
NOTE: Windef.h is included by Windows.h, which is included in nearly every Windows-based program.
Min and max are defined as templated functions in the Standard Template Library (STL). The following definitions of min and max can be found in the file Algobase.h:
Because the Windef.h definition is a macro, the function definitions cause syntax errors when both Windef.h (or Windows.h) and Algobase.h (from the STL) are included. The precise errors will depend on the order in which the two are compiled.
Simply define the NOMINMAX preprocessor symbol. This can be done in the Developer Studio project under Build, Settings, on the C/C++ tab, in the Preprocessor category. This will suppress the min and max definitions in Windef.h.
Article ID: 143208 - Last Review: August 3, 2001 - Revision: 1.0
Retired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.