MinGW错误:'min'不是'std'的成员 [英] MinGW error: 'min' is not a member of 'std'
问题描述
我试图将一些VC ++ 6代码转换为控制台应用程序,只使用标准库,但从MinGW(无论版本是与Code :: Blocks 10.05 IDE)提供以下错误:
I'm trying to convert some VC++ 6 code to a console app using only the standard libraries but am getting the following error from MinGW (whatever version is supplied with the Code::Blocks 10.05 IDE):
error: 'min' is not a member of 'std'
这与以下代码行有关:
L.Precision=std::min(1.e-4,0.001*res);
L.Precision
是 double
, res
是 double
。以前这行是:
L.Precision
is a double
, and res
is a double
. Previously this line was:
L.Precision=min(1.e-4,0.001*res);
但这会产生错误:
error: 'min' was not declared in this scope
是所述文件中的标题:
#include<stdio.h>
#include<math.h>
//#include<algorithm.h>
#include <malloc.h>
#include "complex.h"
#include "mesh.h"
#include "spars.h"
#include "FemmeDocCore.h"
我理解这可能与文件中定义的一些宏相关 windef.h
,但纠正我,如果我错了这个。
I understand that this may be related to some macros defined in the file windef.h
, but correct me if I'm wrong about this.
我该怎么办?我对C ++比较陌生,甚至不确定 windef.h
是否被调用,我认为这只是每个Windows程序所需要的,并添加在一些点击MinGW。
What exactly can I do about this? I'm relatively new to C++, and am not even sure where windef.h
is called for instance, I presume this is just needed for every windows program and is added at some point by MinGW. I want the final code to be cross-platform.
推荐答案
您应该取消注释并修复 #include< ;算法>
,(没有.h),其中 std :: min
被声明。
You should uncomment and fix #include <algorithm>
, (without the .h) which is where std::min
is declared.
这绝对与MinGW或GCC或Windows无关,这是标准的C ++东西。如果您遇到任何其他错误,请在 http://en.cppreference.com/w/ 上搜索缺少的标识符。
This has absolutely nothing to do with MinGW or GCC or Windows, this is standard C++ stuff. If you hit any other errors like this, search for the missing identifier on http://en.cppreference.com/w/.
也可使用< cmath>
和< cstdio>
,并避免 malloc
和朋友,使用 new
/ new []
和 delete
/ delete []
。
Also: use <cmath>
and <cstdio>
, and avoid malloc
and friends, use new
/new[]
and delete
/delete[]
instead.
这篇关于MinGW错误:'min'不是'std'的成员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!