MinGW 错误:'min'不是 'std' 的成员
MinGW error: 'min' is not a member of 'std'
我试图仅使用标准库将一些VC++6代码转换为控制台应用程序,但从MinGW(代码::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=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
中定义的一些宏有关,但如果我错了,请纠正我。
我该怎么办?我对C++还比较陌生,甚至不确定windef.h
在哪里被调用。例如,我认为这只是每个windows程序所需要的,并且是由MinGW在某个时候添加的。我希望最终的代码是跨平台的。
您应该取消注释并修复#include <algorithm>
(不带.h(,std::min
就是在这里声明的。
这与MinGW、GCC或Windows完全无关,这是标准的C++。如果遇到任何其他类似错误,请在上搜索丢失的标识符http://en.cppreference.com/w/.
另外:使用<cmath>
和<cstdio>
,避免使用malloc
和朋友,使用new
/new[]
和delete
/delete[]
。
相关文章:
- std::ofstream 作为类成员删除复制构造函数?
- 使用 std::index_sequence 初始化具有固定大小数组成员的 POD 结构容器
- std::to_string - 'to_string' 不是 'std' 的成员 - Visual Studio Code 1.42.0
- 使用 std::async 时死锁,将来作为成员
- 可变参数模板参数扩展 类型为 std::function 的类成员
- FreeFileSync C++错误:'byte'不是 'std' 的成员
- 为什么 std::sort 找不到合适的(静态成员)函数重载?
- 对带有唯一指针的 std::thread 使用类成员函数时出现编译错误
- 在模板化成员函数的返回类型中使用 std::enable_if 时的编译器差异
- 有没有办法避免为 std::variant 类成员中的所有类型编写构造函数?
- 是否允许类类型的 std::function 成员变量(不完整类型)?
- 访问 std:vector 的类成员 std:vector 在一个类中与另一个 std:vector
- std::异步与非静态成员函数
- 如何在 c++11 中静态断言 std::array 类成员进行排序?
- 将初始化器列表/聚合初始化转发到 std::array 成员
- C++ IDE 不会推断/自动完成对模板类中的 std::array 下标表达式的成员访问
- 在哪里可以找到 std::bitset 的数据成员?
- 没有'str'成员在 GCC 和 Clang 'std::basic_ostream<char>',但 MSVC 没有问题
- unique_ptr问题:不是'std'成员
- std::成员函数的异步调用