std :: min给出错误 [英] std::min gives error
本文介绍了std :: min给出错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
#include <algorithm>
#include <Windows.h>
int main()
{
int k = std::min(3, 4);
return 0;
}
如果我包括Windows.h, :min in visual studio 2005.错误消息是:
What is windows doing, if I include Windows.h I cant use std::min in visual studio 2005. The error message is:
error C2589: '(' : illegal token on right side of '::'
error C2059: syntax error : '::'
推荐答案
windows.h
头文件(或更准确地说, windef.h
turn)的宏具有 min
和 max
的宏。
The windows.h
header file (or more correctly, windef.h
that it includes in turn) has macros for min
and max
which are interfering.
您应该在 #define NOMINMAX
之前加入。
这篇关于std :: min给出错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文